Example #1
0
		f.write(str(datetime.now())+" "+text+"\n")

#LOG ON LOGFILE error
def logError(text):
	with open("/var/log/rpirrigate/error.log","a") as f: 
		f.write(str(datetime.now())+" "+text+"\n")

#SIGNAL HANDLING DEFINITON
signal.signal(signal.SIGUSR1, handUSR1)
signal.signal(signal.SIGUSR2, handUSR2)
signal.signal(signal.SIGHUP, handHUP)

#CATCH **ANY** ERROR AND WRITE ERROR FILE 
try:
	#DATABASE CLASS
	DataBase = DBClass()

	# Settings obj 
	Settings = SettingClass(DataBase)

	#Weather obj 
	Weather = WeatherClass(DataBase, Settings)

	#GPIO obj 
	GPIO = GPIOClass()

	#Create Modules[] array of Modules  objs
	#Every Module create its Events as its M.Events[] in its constructor
	Modules = []
	mods = DataBase.select_module_ids()
	for mod in mods:
Example #2
0
import discord
from datetime import datetime
from DBClass import DBClass
from parser import Parser
from logs import Logs

#Yes, in plain text :(
client = discord.Client()
dbclass = DBClass()
parser = Parser()
logs = Logs()
messages = dbclass.messagesFromDB()


#This is just a function called when the bot is powered up-
#prints a message in the console.
@client.event
async def on_ready():
    messages = dbclass.messagesFromDB()
    print(messages['OnReady1'])
    print(messages['OnReady2'])
    print(messages['OnReady3'])


#This is the 'main' part of the bot e.a. events triggered by specified messages
#sent by users.
@client.event
async def on_message(message):
    #A dictionary of commands from the DB, currently updated on every message
    #for the developement purposes - you might want to FIXME in the future!
    commands = dbclass.commandFromDBParser()
Example #3
0
	text = "EXCEPTION IN (" + str(filename) + ", LINE " + str(lineno) + " '" + str(line.strip()) + "'):" + str(exc_obj);
	with open("/var/log/rpirrigate/error.log","a+") as f: 
		f.write(str(datetime.now())+" "+text+"\n")

#SIGNAL HANDLING DEFINITON
signal.signal(signal.SIGUSR1, handUSR1)
signal.signal(signal.SIGUSR2, handUSR2)
signal.signal(signal.SIGHUP, handHUP)

#WAIT FOR GPIO DAEMON TO CORRECTLY ACTIVATE
sleep(10)

#CATCH **ANY** ERROR AND WRITE ERROR FILE 
try:
	#DATABASE CLASS
	DataBase = DBClass()

	# Settings obj 
	Settings = SettingClass(DataBase)

	#Weather obj 
	Weather = WeatherClass(DataBase, Settings)

	#GPIO obj 
	GPIO = GPIOClass()

	#Create Modules[] array of Modules  objs
	#Every Module create its Events as its M.Events[] in its constructor
	Modules = []
	mods = DataBase.select_module_ids()
	for mod in mods:
Example #4
0
 def __init__(self):
     self.db = DBClass()
     self.file = DBFileConverter(self.db)
Example #5
0
    def __init__(self, p_time, p_mm):
        self.time = p_time
        self.mm = p_mm


def local_to_utc(t):
    secs = time.mktime(t)
    return time.gmtime(secs)


def utc_to_local(t):
    secs = calendar.timegm(t)
    return time.localtime(secs)


DB = DBClass()

#minimum mm to be saved
MIN_MM = 1

city = DB.select1_setting("Location")

now = datetime.datetime.now()
yesterday = now - datetime.timedelta(days=1)

now_date = time.strftime("%Y-%m-%d", now.timetuple())
yesterday_date = time.strftime("%Y-%m-%d", yesterday.timetuple())

#1)   TODAY WEATHER FORECAST

url = "http://api.worldweatheronline.com/free/v2/weather.ashx?q=" + str(
Example #6
0
File: main.py Project: Aioki/db_bot
    def loadDormitory(self):
        self.ui.cb_dormitory.clear()
        res = self.__db.getListDormitory()
        for i in res:
            self.ui.cb_dormitory.addItem(i[0])

    def loadAuditorium(self):
        self.ui.cb_auditorium.clear()
        res = self.__db.getListAuditorium(self.ui.cb_dormitory.currentText())
        for i in res:
            self.ui.cb_auditorium.addItem(str(i[0]))

    def loadCharacter(self):
        self.ui.cb_characher.clear()
        res = self.__db.getListCharacter(self.ui.cb_dormitory.currentText(), self.ui.cb_auditorium.currentText())
        for i in res:
            text = i[1]
            id = i[0]
            if text is None:
                text = "-"
            self.ui.cb_characher.addItem(str(text), id)


if __name__ == '__main__':
    app = QtWidgets.QApplication([])
    database = DBClass("env.json")
    application = mywindow(database)
    application.show()
    sys.exit(app.exec())
class Rain:
	def __init__(self, p_time, p_mm):
		self.time = p_time
		self.mm = p_mm

def local_to_utc(t):
    secs = time.mktime(t)
    return time.gmtime(secs)

def utc_to_local(t):
    secs = calendar.timegm(t)
    return time.localtime(secs)


DB = DBClass()

#minimum mm to be saved
MIN_MM = 1

city = DB.select1_setting("Location")

now = datetime.datetime.now()
yesterday = now - datetime.timedelta(days=1)

now_date = time.strftime("%Y-%m-%d", now.timetuple())
yesterday_date = time.strftime("%Y-%m-%d", yesterday.timetuple())


#1)   TODAY WEATHER FORECAST