def main(opts): import sys # exit from apiclient.errors import HttpError from oauth2client.client import AccessTokenRefreshError from httplib2 import ServerNotFoundError try: main_level2(opts) except KeyboardInterrupt: logs.logs('err', 'Manual interruption ') sys.exit(1) except AccessTokenRefreshError: logs.logs('err', 'The credentials have been revoked or expired, please re-run the application to re-authorize') sys.exit(1) except TypeError as e: # Handle errors in constructing a query. logs.logs('err', 'There was an error in constructing your query : %s' % e) sys.exit(1) except HttpError as e: # Handle API service errors. logs.logs('err', 'There was an API error : %s : %s' % (e.resp.status, e._get_reason())) print(e.content) sys.exit(1) except ServerNotFoundError as e: logs.logs('err', str(e)) sys.exit(1)
def __init__(self, master, nick, balance=0): self.nick = nick self.balance = balance self.path_customers = 'customers\\' self.path_logs = "logs\\" self.log = logs() tk.Toplevel.__init__(self, master) tk.Tk.configure(self, bg="white") tk.Tk.geometry(self, "400x400") tk.Tk.title(self, "Currency Menu") global check self.depo = tk.IntVar() self.check = tk.StringVar(self, "Currency control menu") tk.Label(self, textvariable=self.check, fg="green", font=("Algerian", 13)).pack() tk.Label(self, text="").pack() ###### tk.Label(self, text="Check your current ballance").pack( ) ######## MAIN BODY WITH BUTTONS/ENTRIES ETC. tk.Button(self, text="Check", bg="green", command=self.status).pack() tk.Label(self, text="").pack() self.depo2_entry = tk.Entry(self, bg="yellow") self.depo2_entry.pack() tk.Button(self, text="Deposit", bg="green", command=self.deposit_usd).pack() tk.Label(self, text="").pack() self.with_entry = tk.Entry(self, bg="yellow") self.with_entry.pack() tk.Button(self, text="Withdraw", bg="green", command=self.withdraw_usd).pack() tk.Button(self, text="Transfer", bg="green", command=self.trans_menu).pack()
def __init__(self): tk.Tk.__init__(self) self.logi = logs() self.path_customers = 'customers\\' self.path_logs = "logs\\" self.path_admin = "admin\\" tk.Tk.configure(self, bg="red") tk.Tk.geometry(self, "300x250") tk.Tk.title(self, "Smiglo Bank") tk.Label(self, text="Welcome to Smiglo Bank", bg="pink", font=("Algerian", 13)).pack() tk.Label(self, text="").pack() self.but = tk.Button(self, text="Login", width=20, command=self.login) self.but.pack() tk.Label(self, text="").pack() self.but2 = tk.Button(self, text="Register", width=20, command=self.register) self.but2.pack() tk.Label(self, text="").pack() self.but3 = tk.Button(self, text="Forgot your credentials?", width=20, command=lambda: back(self, self.but3)) self.but3.pack()
def post(self, **params): module = self.get_argument('module', 'missing') if module == 'missing': self.clear() self.set_status(404) self.finish("<html><body>Missing function call</body></html>") return else: Log.Debug('Recieved a post call for module: ' + module) if module == 'logs': self = logs().reqprocessPost(self) elif module == 'settings': self = settings().reqprocessPost(self) elif module == 'pms': self = pms().reqprocessPost(self) elif module == 'findMedia': self = findMedia().reqprocessPost(self) elif module == 'wt': self = wt().reqprocessPost(self) elif module == 'scheduler': self = scheduler().reqprocessPost(self) elif module == 'jsonExporter': self = jsonExporter().reqprocessPost(self) else: self.clear() self.set_status(412) self.finish('Unknown module call') return
def sTART(self): message = [] final = [] PrintersIpAddres = IpAddress() PrintersIPs = PrintersIpAddres.readPrinterInformation() status = PrinterStatus() logger = logs() for x in PrintersIPs: var = x.split() for l in range(0, len(var), 2): ipAddress = var[l] printerLocation = var[l + 1] result = str(status.runStatus(var[l])) if len(result) > 3: message.append(ipAddress) message.append(printerLocation) message.append(result) a = "Printer located near pole " + printerLocation + " with Ip Address " + ipAddress + " is facing the next error " + result + "\n" final.append(a) if (len(final) != 0): multiline_str = ''.join((final)) notifier = notifications() notifier.sendEmail(multiline_str) elif (len(final) == 0): logger.saveEvent("All printers are online \n")
def __init__(self): self.TCP_PORT = 5964 self.BUFFER_SIZE = 1024 self.zplCommand = """ ~HS """ self.register = logs()
def main(): #提示输入参数 parser = optparse.OptionParser('usage %prog -f <xls file name> -p <inpute password>') parser.add_option('-f', dest='fileName', type='string', help='specify xls file name') parser.add_option('-p', dest='password', type='string', help='specify connect scp password') #提取输入参数 (options, args) = parser.parse_args() fileName = options.fileName password = options.password if fileName == None or password == None : print(parser.usage) exit(0) else: #实例化AccessXls对象处理xls文件 accessXlsObj = AccessXls() #实例化Remote对象执行远程代码 remoteObj = Remote() #实例化logs对象执行写入日志信息 logsObj = logs() #打开Xls文件 accessXlsObj.OpenFile(fileName) #获取ip和uuid和数据的数量 ip = accessXlsObj.ReadMessageLine(34) uuid = accessXlsObj.ReadMessageLine(2) count = accessXlsObj.ReadMessageCount() #初始化一个list data = [] #将数据提取到一个list里面 for value in range(count): tmp = {} tmp["ip"] = ip[0] tmp["uuid"] = uuid[0] del ip[0],uuid[0] data.append(tmp) for value in data: #开启写入日志状态 logsObj.Start("../logs/log.txt") #连接到服务器 remoteObj.Connect(value["ip"],'root',password) #传输文件到服务器 os.system("sshpass -p " + password + " scp -r " + catalog + " root@" + value["ip"] + ":/root/") #修改配置文件,server_ip的信息 remoteObj.SendCommand('sed -i -e "s/server_ip =.*/server_ip = ' + value["ip"] + '/g"' + " /root/Linux_agent_minion/config.ini") remoteObj.SendCommand('sed -i -e "s/uuid =.*/uuid = ' + value["uuid"] + '/g"' + " /root/Linux_agent_minion/config.ini") #执行安装agent #remoteObj.SendCommand('cd /root/Linux_agent_minion && bash install.sh') #关闭写入日志状态 logsObj.Close() #打印执行状态 print "ip:" + value["ip"] +" uuid:" + value["uuid"] + " date:" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) +"\033[0;32;40m success\033[0m"
def __init__(self, name, message): ALModule.__init__(self, name) self.message = message self.logs = logs.logs() self.tts = ALProxy("ALTextToSpeech") self.logs.display("Subscribed to an ALTextToSpeech proxy", "Good")
def test_rand(self): from math import log import random def logs_solution(x, a, b): return log(a * b) / log(x) for _ in range(5): base = random.randint(2, 1004) a = random.randint(1, 1004) b = random.randint(1, 1004) self.assertEqual(logs(base, a, b), logs_solution(base, a, b))
def test(self): self.assertEqual(logs(10, 2, 3), 0.7781512503836435) self.assertEqual(logs(5, 2, 3), 1.1132827525593785) self.assertEqual(logs(1000, 2, 3), 0.25938375012788123) self.assertEqual(logs(2, 1, 2), 1) self.assertEqual(logs(0.00001, 0.002, 0.01), 0.9397940008672038) self.assertEqual(logs(0.1, 0.002, 0.01), 4.69897000433602)
def __init__(self, master, nick, kill): self.kill = kill self.nick = nick self.path_customers = "customers\\" self.log = logs() tk.Toplevel.__init__(self, master) tk.Tk.configure(self, bg="white") tk.Tk.geometry(self, "300x250") tk.Tk.title(self, "Currency account creation") tk.Label(self, text = "Currency menu", bg="blue", font = ("Algerian", 13)).pack() tk.Label(self, text="").pack() tk.Button(self, text="Create", bg="green", command=self.create).pack() tk.Label(self, text="").pack()
def get(self, **params): self.set_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') module = self.get_argument('module', 'missing') if module == 'missing': self.clear() self.set_status(404) self.finish('Missing function call') return else: Log.Debug('Recieved a get call for module: ' + module) #TODO ''' Attempt to create a dynamic import, but so far, it sadly breaks access to the PMS API :-( import sys sys.path.append(os.path.join(Core.app_support_path, 'Plug-ins', NAME + '.bundle', 'Contents', 'Code')) mod = import_module(module) modClass = getattr(mod, module)() print 'GED1', dir(modClass) callFunction = getattr(modClass, 'reqprocess') self = modClass().reqprocess(self) ''' if module == 'git': self = git().reqprocess(self) elif module == 'logs': self = logs().reqprocess(self) elif module == 'pms': self = pms().reqprocess(self) elif module == 'settings': self = settings().reqprocess(self) elif module == 'findMedia': self = findMedia().reqprocess(self) elif module == 'jsonExporter': # self = jsonExporter().reqprocess(self) try: m = getattr(module) except Exception, e: print 'Ged json Exception: ' + str(e) elif module == 'language': self = language().reqprocess(self)
def get(self, **params): module = self.get_argument('module', 'missing') if module == 'missing': self.clear() self.set_status(404) self.finish('Missing function call') return else: Log.Debug('Recieved a get call for module: ' + module) #TODO ''' Attempt to create a dynamic import, but so far, it sadly breaks access to the PMS API :-( import sys sys.path.append(os.path.join(Core.app_support_path, 'Plug-ins', NAME + '.bundle', 'Contents', 'Code')) mod = import_module(module) modClass = getattr(mod, module)() print 'GED1', dir(modClass) callFunction = getattr(modClass, 'reqprocess') self = modClass().reqprocess(self) ''' if module == 'git': self = git().reqprocess(self) elif module == 'logs': self = logs().reqprocess(self) elif module == 'pms': self = pms().reqprocess(self) elif module == 'settings': self = settings().reqprocess(self) elif module == 'findMedia': self = findMedia().reqprocess(self) elif module == 'language': self = language().reqprocess(self) elif module == 'plex2csv': self = plex2csv().reqprocess(self) elif module == 'wt': self = wt().reqprocess(self) elif module == 'scheduler': print 'Ged WebSrv Scheduler' self = scheduler().reqprocess(self) else: self.clear() self.set_status(412) self.finish('Unknown module call') return
def get(self, **params): module = self.get_argument('module', 'missing') if module == 'missing': self.clear() self.set_status(404) self.finish('Missing function call') return else: Log.Debug('Recieved a get call for module: ' + module) #TODO ''' Attempt to create a dynamic import, but so far, it sadly breaks access to the PMS API :-( import sys sys.path.append(os.path.join(Core.app_support_path, 'Plug-ins', NAME + '.bundle', 'Contents', 'Code')) mod = import_module(module) modClass = getattr(mod, module)() print 'GED1', dir(modClass) callFunction = getattr(modClass, 'reqprocess') self = modClass().reqprocess(self) ''' if module == 'git': self = git().reqprocess(self) elif module == 'logs': self = logs().reqprocess(self) elif module == 'pms': self = pms().reqprocess(self) elif module == 'settings': self = settings().reqprocess(self) elif module == 'findMedia': self = findMedia().reqprocess(self) elif module == 'language': self = language().reqprocess(self) elif module == 'plex2csv': self = plex2csv().reqprocess(self) elif module == 'wt': self = wt().reqprocess(self) else: self.clear() self.set_status(412) self.finish('Unknown module call') return
def post(self, **params): module = self.get_argument('module', 'missing') if module == 'missing': self.clear() self.set_status(404) self.finish("<html><body>Missing function call</body></html>") return else: Log.Debug('Recieved a post call for module: ' + module) if module == 'logs': self = logs().reqprocessPost(self) elif module == 'settings': self = settings().reqprocessPost(self) elif module == 'pms': self = pms().reqprocessPost(self) elif module == 'findUnmatched': self = findUnmatched().reqprocessPost(self) else: self.clear() self.set_status(412) self.finish("<html><body>Unknown module call</body></html>") return
def get(self, **params): module = self.get_argument('module', 'missing') if module == 'missing': self.clear() self.set_status(404) self.finish("<html><body>Missing function call</body></html>") return else: Log.Debug('Recieved a get call for module: ' + module) #TODO ''' import sys sys.path.append(os.path.join(Core.app_support_path, 'Plug-ins', NAME + '.bundle', 'Contents', 'Code')) mod = import_module(module) modClass = getattr(mod, module)() print 'GED1', dir(modClass) callFunction = getattr(modClass, 'reqprocess') self = modClass().reqprocess(self) ''' if module == 'git': self = git().reqprocess(self) elif module == 'logs': self = logs().reqprocess(self) elif module == 'pms': self = pms().reqprocess(self) elif module == 'settings': self = settings().reqprocess(self) elif module == 'findUnmatched': self = findUnmatched().reqprocess(self) else: self.clear() self.set_status(412) self.finish("<html><body>Unknown module call</body></html>") return
def __init__(self, master, nick): self.nick = nick self.path_logs = "logs\\" self.logs = logs() tk.Toplevel.__init__(self, master) tk.Tk.configure(self, bg="white") tk.Tk.geometry(self, "300x250") tk.Tk.title(self, "Transfer Menu") tk.Label(self, text="DO you transfers", bg="blue", font=("Algerian", 13)).pack() tk.Label(self, text="").pack() global tescik global tescik2 self.tescik = tk.Entry(self, bg="yellow") self.tescik.insert(0, "Put user here") self.tescik.pack() tk.Label(self, text="").pack() self.tescik2 = tk.Entry(self, bg="yellow") self.tescik2.insert(0, "Put amount here") self.tescik2.pack() tk.Button(self, text="transfer", bg="green", command=self.send).pack()
def __init__(self, login, password, code): self.login = login self.logs = logs() self.password = password self.code = code self.path_customers = 'customers\\' self.path_logs = "logs\\" self.path_admin = "admin\\" tk.Tk.__init__(self) with open(self.path_admin+self.login, "r") as file: lines = file.readlines() with open(self.path_admin+self.login, "w") as file2: lines[3] = 'ONLINE' for x in lines: file2.write(x) tk.Tk.protocol(self,'WM_DELETE_WINDOW', self.offline_switch) tk.Tk.geometry(self,"400x400") tk.Tk.title(self, "Admin menu") tk.Label(self, text='Open user details').pack() self.info = tk.Entry(self, bg="yellow") self.info.pack() tk.Button(self, text='proceed', command=self.get_user).pack() tk.Label(self, text="").pack() tk.Label(self, text="Delete user account").pack() self.info2 = tk.Entry(self, bg="yellow") self.info2.pack() tk.Button(self, text='proceed', command=self.delete).pack() tk.Label(self, text="").pack() tk.Label(self, text="Suspend user account").pack() self.info3 = tk.Entry(self, bg="yellow") self.info3.pack() tk.Button(self, text='proceed', command=self.ban).pack() tk.Label(self, text="").pack() tk.Label(self, text="Unsuspend user account").pack() self.info4 = tk.Entry(self, bg="yellow") self.info4.pack() tk.Button(self, text='proceed', command=self.unban).pack()
import pymysql import csv import logs import pymysql.cursors from pymysql import OperationalError try: logger = logs.logs() # Database connection connection = pymysql.connect( host='localhost', user='******', password='', db='scraperdb1', ) print("Database Connection Established") logger.info("Database Connection Established") cursor = connection.cursor() cursor1 = connection.cursor() cursor2 = connection.cursor() cursor3 = connection.cursor() cursor4 = connection.cursor() except OperationalError as e: print('Invalid Database Creditentials') logger.critical('Invalid Database Creditentials')
def __init__( self, name, password, code, balance=0 ): ## Script opens for person who provide login/password/security code self.balance = balance self.name = name self.password = password self.code = code self.log = logs() self.path_logs = "logs\\" self.log.log_on(self.name) tk.Tk.__init__(self) status(self.name) #///// sets user's status to ONLINE tk.Tk.title(self, "Smiglo bank " + 'logged as: ' + str(self.name)) tk.Tk.geometry(self, "400x500") tk.Tk.protocol(self, 'WM_DELETE_WINDOW', self.x_disable) tk.Label(self, text="").pack() tk.Label(self, text="").pack() tk.Button(self, text="deposit", bg="red", command=self.deposit).pack() ##### Main Body self.depo_entry = tk.Entry(self, bg="yellow") self.depo_entry.pack() tk.Button(self, text="withdraw", bg="red", command=self.withdraw).pack() self.withh_entry = tk.Entry(self, bg="yellow") self.withh_entry.pack() tk.Label(self, text="").pack() tk.Label(self, text="").pack() tk.Button(self, text="Check balance", bg="red", command=self.check).pack() tk.Label(self, text="").pack() tk.Label(self, text="").pack() tk.Button(self, text="Log Off", bg="pink", command=self.log_off).pack(side=tk.BOTTOM) tk.Tk.after(self, 100, self.currency_check) tk.Tk.after(self, 100, self.token_check) # Submenus menu = tk.Menu(self) tk.Tk.config(self, menu=menu) Sub = tk.Menu(menu) menu.add_cascade(label="transfers", menu=Sub) ##//////// Submenu for transfers Sub.add_command(label="Do transfer", command=lambda: trans(self, self.name)) Sub2 = tk.Menu(menu) menu.add_cascade(label="Currency", menu=Sub2) #//////// SuBmenu for currency Sub2.add_command(label="Currency manu", command=self.currency) Sub3 = tk.Menu(menu) menu.add_cascade(label="Admin chat", menu=Sub3) Sub3.add_command( label="Open admin chat", command=lambda: admin_chat(self, self.name, self.password, self. code) ) #////// admin chat (currently only shows if admin ONLINE) Sub4 = tk.Menu(menu) menu.add_cascade(label="Roulete", menu=Sub4) Sub4.add_command( label="Play roulete", command=lambda: roulete(self, self.name)) #////// roulete game Sub5 = tk.Menu(menu) menu.add_cascade(label="Lotto", menu=Sub5) Sub5.add_command( label="Play lotto", command=lambda: lotto_los(self, self.name)) #////// lotto game Sub6 = tk.Menu(menu) menu.add_cascade(label="shop", menu=Sub6) Sub6.add_command(label="Play lotto", command=self.Go_to_shop)
def sync_events(calendar, lessons, begin, end, service, opts): import binascii (old, deleted) = event.list(service, calendar, begin, end, opts) begin = int(begin) end = int(end) lessons = {k:v for (k,v) in lessons.items() if v['start'] < end and v['end'] > begin} # delete ids = set(old.keys()) - set(lessons.keys()) i = 1 count = len(ids) if count > 0: logs.logs('h4', 'Deleting') for id in ids: logs.logs(None, '{}/{} {}'.format(i, count, id)) event.delete(service, calendar, id) i = i + 1 # insert ids = set(lessons.keys()) - set(old.keys()) - set(deleted.keys()) i = 1 count = len(ids) if count > 0: logs.logs('h4', 'Inserting') for id in ids: logs.logs(None, '{}/{} {}'.format(i, count, id)) event.insert(service, calendar, lessons[id]) i = i + 1 # update ids = set(lessons.keys()) & set(deleted.keys()) i = 1 count = len(ids) if count > 0: logs.logs('h4', 'Updating') for id in ids: logs.logs(None, '{}/{} {}'.format(i, count, id)) event.update(service, calendar, lessons[id]) i = i + 1
def main_level2(opts): from datetime import datetime flags = args() now = datetime.now() now = now.strftime('%Y-%m-%d %H:%M:%S') logs.logs(None, 'Now: ' + now) logs.logs('h1', 'Arguments') for (k, v) in flags.__dict__.items(): if k in ['begin', 'end'] and v is not None: logs.logs(None, k + ' = ' + str(datetime.fromtimestamp(float(v)))) else: logs.logs(None, k + ' = ' + str(v)) events = untis.untis(flags.untis_xml_file, opts) if flags.sync == 'none': import sys logs.logs(None, 'Finish') sys.exit() if flags.begin is None: begin = events['termbegin'] else: begin = flags.begin if flags.end is None: end = events['termend'] else: end = flags.end service = login.login(flags, opts) for (section, field, prefix) in sections: if flags.sections != 'all' and section != flags.sections: continue logs.logs('h1', 'Section ' + section) sync = flags.sync in ['all', 'calendars'] if sync: logs.logs('h2', 'Syncing Calendar') cal_delete = flags.calendar_delete_allow id2cal = sync_calendars(service, events[section], sync, cal_delete, prefix, opts) if flags.sync not in ['all', 'events']: continue i = 1 count = len(id2cal) for id2, calendar in id2cal.items(): if isinstance(flags.id, str) and id2 != flags.id: continue elif flags.id is None: logs.logs('h3', '{:02d}% Syncing events in {}'.format(int(100 * i / count), calendar['summary'])) else: logs.logs('h3', 'Syncing events in {}'.format(calendar['summary'])) i = i + 1 id = calendar['id'] lessons = untis.dofilter(events['lessons'], field, id2) sync_events(id, lessons, begin, end, service, opts) logs.logs(None, 'Finish')
def sync_calendars(service, id2summary, sync, delete, id_prefix, opts): active = calendarlist.list(service) active_id2 = calendarlist.id2map(active) deleted = set(active_id2.keys()) - set(id2summary.keys()) import re deleted = filter(lambda x: re.match(r'^' + id_prefix + '_', x), deleted) deleted = list(deleted) if len(deleted) > 0: if delete: logs.logs('h3', 'Deleting calendars') i = 1 count = len(deleted) for id in deleted: cal = active_id2[id] logs.logs(None, '{:02d}% {}: {}'.format(int(100 * i / count), id, cal['summary'])) calendarlist.delete(service, cal['id']) i = i + 1 else: logs.logs('h3', 'Redundant calendars') for id in deleted: cal = active_id2[id] logs.logs(None, id + ': ' + cal['summary']) logs.logs(None, 'You can delete calendars in one of following ways:') logs.logs(None, '* Use Google web interface.') logs.logs(None, '* Use gcal_rm.') logs.logs(None, '* Specify --calendar_delete_allow or -d.') if sync: logs.logs('h3', 'Checking/inserting/updating calendars') i = 1 count = len(id2summary) for id2, summary in id2summary.items(): # this is "goto end" replacement if not sync: break logs.logs(None, '{:02d}% {}'.format(int(100 * i / count), summary)) i = i + 1 if id2 in active_id2: calendar = active_id2[id2] id = calendar['id'] else: calendar = { 'summary': summary, 'description': calendars.encode(id2), } calendar = calendars.insert(service, calendar, opts) id = calendar['id'] calendar = calendarlist.get(service, id) calendar = { 'id': calendar['id'], 'selected': False, } calendar = calendarlist.patch(service, calendar) active[id] = calendar active_id2[id2] = calendar # now we have: id, id2, calendar # check if need to patch calendar settings patch = {} if calendar['summary'] != summary: patch['summary'] = summary encoded = calendars.encode(id2) if calendar['description'] != encoded: patch['description'] = encoded if calendar['location'] != opts['location']: patch['location'] = opts['location'] if calendar['timeZone'] != opts['timezone']: patch['timeZone'] = opts['timezone'] if len(patch) > 0: patch['id'] = id calendars.patch(service, patch) # check if need to update acl # { # 'scope': { # 'type': 'default', # 'value': '*****@*****.**' # }, # 'kind': 'calendar#aclRule', # 'etag': '"00001430601714475000"', # 'role': 'reader', # 'id': 'default' # } acls = acl.list(service, id) update = True role = 'reader' typ = 'default' value = opts['public_calendar'] for k, a in acls.items(): if True \ and a['role'] == role \ and a['scope']['type'] == typ \ and a['scope']['value'] == value \ : update = False break if update: acl.insert(service, id, { 'role': role, 'scope': { 'type': typ, 'value': 'default', }, }) ret_id2 = {} for id2 in id2summary: ret_id2[id2] = active_id2[id2] return ret_id2
def __init__( self, name, password, code, balance=0 ): ## Script opens for person who provide login/password/security code self.balance = balance self.name = name self.password = password self.code = code self.log = logs() self.path_customers = "customers\\" self.path_logs = "logs\\" tk.Tk.__init__(self) with open(self.path_customers + self.name, "r") as file: lines = file.readlines() with open(self.path_customers + self.name, "w") as file2: lines[8] = "ONLINE" + '\n' for x in lines: file2.write(x) tk.Tk.title(self, "Smiglo bank " + 'logged as: ' + str(self.name)) tk.Tk.geometry(self, "400x500") tk.Tk.protocol(self, 'WM_DELETE_WINDOW', self.x_disable) tk.Label(self, text="").pack() tk.Label(self, text="").pack() tk.Button(self, text="deposit", bg="red", command=self.deposit).pack() ##### Main Body self.depo_entry = tk.Entry(self, bg="yellow") self.depo_entry.pack() tk.Button(self, text="withdraw", bg="red", command=self.withdraw).pack() self.withh_entry = tk.Entry(self, bg="yellow") self.withh_entry.pack() tk.Label(self, text="").pack() tk.Label(self, text="").pack() tk.Button(self, text="Check balance", bg="red", command=self.check).pack() tk.Label(self, text="").pack() tk.Label(self, text="").pack() tk.Button(self, text="Log Off", bg="pink", command=self.log_off).pack(side=tk.BOTTOM) tk.Tk.after(self, 100, self.currency_check) tk.Tk.after(self, 100, self.token_check) # Submenus menu = tk.Menu(self) tk.Tk.config(self, menu=menu) Sub = tk.Menu(menu) menu.add_cascade(label="transfers", menu=Sub) ##### Submenu for transfers Sub.add_command(label="Do transfer", command=lambda: trans(self, self.name)) ###### Sub2 = tk.Menu(menu) menu.add_cascade(label="Currency", menu=Sub2) ##### SuBmenu for currency Sub2.add_command(label="Currency manu", command=self.currency) ####### Sub3 = tk.Menu(menu) menu.add_cascade(label="Admin chat", menu=Sub3) Sub3.add_command(label="Open admin chat", command=lambda: admin_chat(self, self.name, self. password, self.code)) Sub4 = tk.Menu(menu) menu.add_cascade(label="Roulete", menu=Sub4) Sub4.add_command(label="Play roulete", command=lambda: roulete(self, self.name)) Sub5 = tk.Menu(menu) menu.add_cascade(label="Lotto", menu=Sub5) Sub5.add_command(label="Play lotto", command=lambda: lotto_los(self, self.name))
def untis(file, opts): import logs logs.logs('h1', 'Untis import') logs.logs(None, 'File: ' + file) from datetime import datetime # import base64 # broken import binascii import os import re import sys import time import xml.etree.ElementTree as ET os.environ['TZ'] = opts['timezone'] time.tzset() # print('Reading XML from stdin ...') # file = "\n".join(sys.stdin) # tree = ET.fromstring(file) tree = ET.parse(file) tree = ET.ElementTree(tree) root = tree.getroot() termbegin = root.find('general').find('termbegindate').text termbegin = datetime.strptime(termbegin, '%Y%m%d') logs.logs(None, 'Term Begin: ' + termbegin.strftime('%Y-%m-%d')) termbegin = termbegin.strftime('%s') termbegin = int(termbegin) termend = root.find('general').find('termenddate').text termend = datetime.strptime(termend, '%Y%m%d') logs.logs(None, 'Term End: ' + termend.strftime('%Y-%m-%d')) termend = termend.strftime('%s') termend = int(termend) rooms = {} for room in root.find('rooms'): id = room.attrib['id'] id2 = re.sub(r'^RM_', '', id) longname = room.find('longname') if longname is None: rooms[id] = id2 else: rooms[id] = id2 + ' ' + strip(longname.text) logs.logs(None, 'Rooms: ' + str(len(rooms))) subjects = {} for subject in root.find('subjects'): id = subject.attrib['id'] id2 = re.sub(r'^SU_', '', id) longname = subject.find('longname') if longname is None: subjects[id] = id2 else: subjects[id] = strip(longname.text) teachers = {} for teacher in root.find('teachers'): id = teacher.attrib['id'] id2 = re.sub(r'^TR_', '', id) surname = teacher.find('surname') if surname is None: teachers[id] = id2 else: teachers[id] = strip(surname.text) logs.logs(None, 'Teachers: ' + str(len(teachers))) classes = {} for clss in root.find('classes'): id = clss.attrib['id'] id2 = re.sub(r'^CL_', '', id) longname = clss.find('longname') if longname is None: classes[id] = id2 else: classes[id] = strip(longname.text) logs.logs(None, 'Classes: ' + str(len(classes))) lessons = {} for lesson in root.find('lessons').findall('lesson'): subject_id = lesson.find('lesson_subject') if subject_id is None: subject = '' subject_id = '' else: subject_id = subject_id.attrib['id'] subject = subjects[subject_id] teacher_id = lesson.find('lesson_teacher') if teacher_id is None: teacher = '' teacher_id = '' else: teacher_id = teacher_id.attrib['id'] teacher = teachers[teacher_id] times = lesson.find('times') # class id-s may contain spaces, yuck! class_ids = lesson.find('lesson_classes') if class_ids is None: class_ids = [''] else: class_ids = class_ids.attrib['id'] class_ids = re.split(r'\s*CL_', class_ids) class_ids = filter(lambda x: len(x) > 0, class_ids) class_ids = map(lambda x: 'CL_' + x, class_ids) for class_id in class_ids: class_id = class_id if len(class_id) > 0: clAss = classes[class_id] else: clAss = '' for time in times: room = time.find('assigned_room') if room is None: room_id = '' room = '' else: room_id = room.attrib['id'] room = rooms[room_id] date = time.find('assigned_date').text start0 = time.find('assigned_starttime').text start = datetime.strptime(date + start0, '%Y%m%d%H%M').strftime('%s') start = int(start) end0 = time.find('assigned_endtime').text end = datetime.strptime(date + end0, '%Y%m%d%H%M').strftime('%s') end = int(end) id = [subject_id, teacher_id, class_id, room_id, str(start), str(end)] id = ':'.join(id) # b32encode() is unable to handle unicode id = id.encode('ascii', 'xmlcharrefreplace') # id = base64.b32encode(id) # broken id = binascii.hexlify(id) id = id.decode('utf-8') id = id.lower() lessons[id] = { 'id': id, 'subject_id': subject_id, 'subject': subject, 'teacher_id': teacher_id, 'teacher': teacher, 'room_id': room_id, 'room': room, 'class_id': class_id, 'class': clAss, 'start': start, 'end': end, # for debugging timezone # 'start0': start0, # 'end0': end0, 'timezone': opts['timezone'], } logs.logs(None, 'Lessons: ' + str(len(lessons))) return { 'termbegin': termbegin, 'termend': termend, 'rooms': rooms, 'classes': classes, 'subjects': subjects, 'teachers': teachers, 'lessons': lessons }
def __init__(self,name): self.name = name ALModule.__init__(self, name) # Create new object display a colored message on computer's terminal. self.logs = logs.logs() # Create new proxies. self.tts = ALProxy("ALTextToSpeech", IP, port) self.logs.display("Subscribed to an ALTextToSpeech proxy", "Good") self.motion = ALProxy("ALMotion", IP, port) self.motion.moveInit() self.logs.display("Subscribed to an ALMotion proxy", "Good") self.posture = ALProxy("ALRobotPosture") self.logs.display("Subscribed to an ALRobotPosture proxy", "Good") self.leds = ALProxy("ALLeds") self.logs.display("Subscribed to an ALLeds proxy", "Good") self.RedTracker = ALProxy("ALRedBallTracker") self.logs.display("Subscribed to an ALRedBallTracker proxy", "Good") self.RemoteTx = ALProxy("ALInfrared") self.RemoteTx.initReception(3) self.logs.display("Subscribed to an ALInfrared proxy", "Good") self.NCProxy = ALProxy("NaoChallengeGeoloc",IP,port) try: self.NCProxy.registerToVideoDevice(definition, colors) self.logs.display("Subscribed to an NaoChallengeGeoloc proxy", "Good") except: self.logs.display("NaoChallengeGeoloc proxy already registered", "Warning") self.NCMotion = TimelinesModule() self.logs.display("Timelines initialisation", "Good") self.sonarProxy = ALProxy("ALSonar", ip, 9559) self.logs.display("Subscribed to an ALSonar proxy", "Good") self.memoryProxy = ALProxy("ALMemory", ip, 9559) self.logs.display("Subscribed to an ALMemory proxy", "Good") # Prepare Nao. self.posture.goToPosture("StandInit", 1.0) self.logs.display("Nao is going to posture StandInit","Good") self.EventsInit() self.logs.display("tactil initialisation","Good") # Ready! print ("--------------------------------------------------------------------------") print ("--------------------------------------------------------------------------") self.logs.display("Module ready", "Good")