def func4(severity): try: lst = [] print lst['name'] except: data = {'list': lst} Debug.log(project='Test', sub_system='sub', severity=severity, data=data)
def func2(severity): try: dic = {} print dic['name'] except: data = {'dic': dic} Debug.log(project='Test', sub_system='sub', severity=severity, data=data)
def func1(severity): try: a = 12 b = 0 print a / b except: data = {'a': a, 'b': b} Debug.log(project='Test', sub_system='sub', severity=severity, data=data)
def run(self): try: index = 1 value = None last_update = datetime.now() found = False Debug.head("Car Scanner") Debug.log('ID | Idle RPM | Max RPM | Max Gears') if self.callback is not None: self.callback("Car Scanner") self.callback('ID | Idle RPM | Max RPM | Max Gears') while not self.finished: if last_update is not None: delta = datetime.now() - last_update if delta.seconds >= 30: Debug.notice('New track') found = False last_update = datetime.now() try: data, address = self.sock.recvfrom(512) except socket.timeout: continue except socket.error: break if not data: continue if found: continue stats = struct.unpack('66f', data[0:264]) new_value = "%.14f;%.14f;%d" % \ (stats[Telemetry.IDLE_RPM], stats[Telemetry.MAX_RPM], int(stats[Telemetry.MAX_GEARS])) if new_value != value: value = new_value Debug.log(value, '%d' % index) if self.callback is not None: self.callback('%d;%s' % (index, value)) index += 1 found = True except Exception as e: Debug.warn(e)
def post(self, *args, **kwargs): try: dict = json.loads(self.get_argument('dict', 'empty')) # print(dict) # print('OK SIR') # print(dict) # print(dict['person']) obj = Domain() obj.name = dict['domain'] # obj.name = 'domain.ir' obj.last_updated = dict['last_updated'][14:] obj.expire_date = dict['expire_date'][13:] obj.person = dict['person'][9:] obj.email = dict['email'][9:] obj.address = dict['address'][9:] obj.phone = dict['phone'][8:] obj.fax = dict['fax'][9:] # Debug.cprint(text='All set' , color=Debug.BLUE) Debug.log(name='add_domain', data='All Set') #TODO Check for existing domain, If necessary update it obj.save() except Exception, e: Debug.log(name='add_domain', data='Error:' + e.message)
def run(self): try: if self.game['db_file'] is None: return app_root = os.path.dirname(os.path.realpath(__file__)) data_path = '/../data/' if getattr(sys, 'frozen', False): data_path = '/data/' conn = sqlite3.connect(app_root + data_path + self.game['db_file']) db = conn.cursor() index = 1 value = None last_update = datetime.now() found = False Debug.head("Track Scanner") Debug.log('ID | Name | Track Length | Z POS | Laps') if self.callback is not None: self.callback("Track Scanner") self.callback('ID | Name | Track Length | Z POS | Laps') while not self.finished: if last_update is not None: delta = datetime.now() - last_update if delta.seconds >= 10: found = False last_update = datetime.now() try: data, address = self.sock.recvfrom(512) except socket.timeout: continue except socket.error: break if not data: print('no data') continue if found: print('found') continue stats = struct.unpack('66f', data[0:264]) new_value = "%.14f;%d;%d" % \ ( stats[Telemetry.TRACK_LENGTH], int(stats[Telemetry.Z_POSITION]), int(stats[Telemetry.TOTAL_LAPS]) ) if new_value != value: value = new_value index += 1 db.execute( 'SELECT id,name FROM Tracks WHERE length = ? AND (start_z = "" OR round(start_z) = ?)', (stats[Telemetry.TRACK_LENGTH], stats[Telemetry.Z_POSITION])) res = db.fetchall() track_name = 'unknown' track_index = -1 if len(res) >= 1: for (index, name) in res: track_index = index track_name = name break Debug.log('%d;%s;%s' % (track_index, track_name, value)) if self.callback is not None: self.callback('%d;%s;%s' % (track_index, track_name, value)) found = True Debug.notice('Scan loop ended') if db is not None: db.close() if conn is not None: conn.close() except sqlite3.Error as e: Debug.err("Database connection error") Debug.err(e) except Exception as e: Debug.warn(e)