Python Forum
Python code with serial port and global undefined
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python code with serial port and global undefined
#11
# 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.
Reply
#12
(Jan-17-2017, 01:43 PM)marciokoko Wrote: But then again I copied from my previous post
Yeah, 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).
Reply
#13
# 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()
Reply
#14
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PC why serial code = converting to ascii ? trix 11 4,527 Oct-12-2024, 11:10 PM
Last Post: deanhystad
  pyserial/serial "has no attribute 'Serial' " gowb0w 11 33,589 Sep-27-2024, 12:18 PM
Last Post: NigelHalse
  Waiting for input from serial port, then move on KenHorse 3 5,771 Apr-17-2024, 07:21 AM
Last Post: DeaD_EyE
  MCU reboots after opening Serial port when ran from Raspberry PI zazas321 3 2,540 Mar-19-2024, 09:02 AM
Last Post: zazas321
  Python error on mentioned Arduino port name dghosal 5 3,115 Aug-22-2023, 04:54 PM
Last Post: deanhystad
  Why Pip is not listed in the official Global Python Module index? quazirfan 2 1,935 Apr-21-2023, 10:55 AM
Last Post: snippsat
  Serial Port As Global Prasanjith 2 3,800 Mar-23-2023, 08:54 PM
Last Post: deanhystad
  Python Serial: How to read the complete line to insert to MySQL? sylar 1 2,264 Mar-21-2023, 10:06 PM
Last Post: deanhystad
  undefined function error JonWayn 5 3,310 Sep-11-2022, 03:38 AM
Last Post: JonWayn
  Undefined Led_Zeppelin 4 3,011 Aug-02-2022, 11:57 AM
Last Post: buran

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.