Python Forum
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check presence of a file
#7
I followed killerex'es suggestion and made base.py

#!/bin/python

# baseprogram; calls the function status from key_check.py

import sys
import os
import time

from key_check import status

while True:
    
    on_or_off=status
    print (on_or_off)
    time.sleep(3)
and key_check.py that containes the function 'status'

#!/bin/python
 
#import RPi.GPIO as GPIO
import time
import os 

#GPIO.setup(22, GPIO.IN)

def status():
    foo = 5     # Lees de status van de GPIO pin uit.
    if (foo) == 4:
      #Schakelaar is AAN.
      key = 'ON'
    else:
      #Schakelaar is UIT.
      key = 'OFF'
    return (key)
      
datum = (time.strftime('%d/%m/%Y'))
#print(datum)
#keystat = status()
#print (keystat)

def _test():

   pass
 
if __name__ == '__main__':
    # This part runs only when this script is the main script, not when imported from other
    _test()
Running key_check on its own is OK.
When i call keycheck.status i get the following response:

Output:
Python 3.6.4 >>> %Run base.py <function status at 0x037E4E40> <function status at 0x037E4E40> KeyboardInterrupt: Forced reset >>>
Any ideas about this?
As you will probably have noticed i am very much a novice, but i'll learn.
is there a site where i can learn about those situation?
Reply


Messages In This Thread
Check presence of a file - by Steffenwolt - May-20-2018, 04:28 PM
RE: Check presence of a file - by killerrex - May-20-2018, 05:58 PM
RE: Check presence of a file - by Steffenwolt - May-21-2018, 09:37 AM
RE: Check presence of a file - by buran - May-21-2018, 09:38 AM
RE: Check presence of a file - by Steffenwolt - May-21-2018, 03:58 PM
RE: Check presence of a file - by killerrex - May-21-2018, 05:43 PM
RE: Check presence of a file - by Steffenwolt - May-23-2018, 08:31 PM
RE: Check presence of a file - by killerrex - May-24-2018, 07:50 AM
RE: Check presence of a file - by Steffenwolt - May-25-2018, 07:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  please check this i wanna use a csv file as a graph xCj11 5 1,617 Aug-25-2022, 08:19 PM
Last Post: deanhystad
  check if a file exist on the internet and get the size kucingkembar 6 1,908 Apr-16-2022, 05:09 PM
Last Post: kucingkembar
  Code to check folder and sub folders for new file and alert fioranosnake 2 2,064 Jan-06-2022, 05:03 PM
Last Post: deanhystad
  Check last time file was accessed Pavel_47 4 2,931 Jun-01-2021, 05:47 PM
Last Post: Yoriz
  How to check if a file has finished being written leocsmith 2 8,122 Apr-14-2021, 04:21 PM
Last Post: perfringo
  Check if a file exists. Pedroski55 5 3,418 Sep-08-2020, 10:01 AM
Last Post: Pedroski55
  How to check to see a dbf file is EOF ? DarkCoder2020 0 1,785 Jun-16-2020, 05:03 PM
Last Post: DarkCoder2020
  Building a script to check size of file upon creation mightyn00b 2 2,451 Apr-04-2020, 04:39 AM
Last Post: Larz60+
  MySql - Loop - CHeck File gcclinux 1 2,153 Nov-30-2019, 11:51 AM
Last Post: ThomasL
  Checking the presence of label using pywinauto module Malt 0 1,997 Jul-26-2019, 09:06 AM
Last Post: Malt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020