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
  Waiting for input from serial port, then move on KenHorse 3 998 Apr-17-2024, 07:21 AM
Last Post: DeaD_EyE
  MCU reboots after opening Serial port when ran from Raspberry PI zazas321 3 427 Mar-19-2024, 09:02 AM
Last Post: zazas321
  pyserial/serial "has no attribute 'Serial' " gowb0w 9 3,878 Aug-24-2023, 07:56 AM
Last Post: gowb0w
  Python error on mentioned Arduino port name dghosal 5 847 Aug-22-2023, 04:54 PM
Last Post: deanhystad
  Why Pip is not listed in the official Global Python Module index? quazirfan 2 755 Apr-21-2023, 10:55 AM
Last Post: snippsat
  Serial Port As Global Prasanjith 2 1,483 Mar-23-2023, 08:54 PM
Last Post: deanhystad
  Python Serial: How to read the complete line to insert to MySQL? sylar 1 817 Mar-21-2023, 10:06 PM
Last Post: deanhystad
  undefined function error JonWayn 5 1,440 Sep-11-2022, 03:38 AM
Last Post: JonWayn
  Undefined Led_Zeppelin 4 1,409 Aug-02-2022, 11:57 AM
Last Post: buran
  python serial port barryjo 2 1,652 Dec-27-2021, 11:09 PM
Last Post: barryjo

Forum Jump:

User Panel Messages

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