Python code with serial port and global undefined - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python code with serial port and global undefined (/thread-1605.html) Pages:
1
2
|
RE: Python code with serial port and global undefined - marciokoko - Jan-17-2017 # class to hold read and write #!/usr/bin/env python import serial import logging import time, datetime from firebase import firebase from firebase_token_generator import create_token from apscheduler.schedulers.blocking import BlockingScheduler class AIHome: def __init__(self, onTime, offTime): self.onTime=onTime self.offTime=offTime self.updateInterval = 6 self.webPush = False self.relayStatesA = [] self.relayStatesD = {} logging.basicConfig() #Call fetchUpdate every 6 hours print('initting AIHome...scheduling job') sched = BlockingScheduler() @sched.scheduled_job('interval', hours=1) def timed_job(): print('This job runs every 6 hrs. timed_job gets called or something else') #call fetchUpdate() self.fetchUpdate(); sched.configure() #options_from_ini_file sched.start()Well it didnt work. But then again I copied from my previous post, so Ill try doing it from TW. RE: Python code with serial port and global undefined - micseydel - Jan-17-2017 (Jan-17-2017, 01:43 PM)marciokoko Wrote: But then again I copied from my previous postYeah, it's already gone from your previous post, if we could do it from your post then we wouldn't need to give you the runaround :) You'll definitely need to copy from a source that has the indentation, preferably a programming-oriented text editor (Text Wrangler should be fine). RE: Python code with serial port and global undefined - marciokoko - Jan-17-2017 # class to hold read and write #!/usr/bin/env python import serial import logging import time, datetime from firebase import firebase from firebase_token_generator import create_token from apscheduler.schedulers.blocking import BlockingScheduler class AIHome: def __init__(self, onTime, offTime): self.onTime=onTime self.offTime=offTime self.updateInterval = 6 self.webPush = False self.relayStatesA = [] self.relayStatesD = {} logging.basicConfig() #Call fetchUpdate every 6 hours print('initting AIHome...scheduling job') sched = BlockingScheduler() @sched.scheduled_job('interval', hours=1) def timed_job(): print('This job runs every 6 hrs. timed_job gets called or something else') #call fetchUpdate() self.fetchUpdate(); #RUNS AT DAY&TIME SPECIIFIED########################### #@sched.scheduled_job('cron', day_of_week='mon-fri', hour=12) #def scheduled_job(): # print('This job is run every weekday at 12pm.') ####################################################### sched.configure() #options_from_ini_file sched.start() RE: Python code with serial port and global undefined - micseydel - Jan-17-2017 That code just defines a class. We need a runnable snippet that will reproduce the problem. The code you've posted here doesn't even have the code referenced by your original error message. |