def wrap(*args, **kwargs): res = utils.init_response_data() try: res = f(*args, **kwargs) res["message"] = status.Status().getReason(res["code"]) except Exception, e: res["code"] = status.Status.ERROR res["message"] = status.Status().getReason(res["code"]) _logger.exception("An exception occured during an http request") se = _serialize_exception(e) error = {'code': 200, 'message': "Odoo Server Error", 'data': se} res["error_info"] = error return simplejson.dumps(res)
def wrap(*args, **kwargs): res = utils.init_response_data() try: res = f(*args, **kwargs) res["message"] = status.Status().getReason(res["code"]) except Exception, e: res["code"] = status.Status.ERROR res["message"] = status.Status().getReason(res["code"]) _logger.exception("An exception occured during an http request") se = _serialize_exception(e) error = {'code': 200, 'message': "Odoo Server Error", 'data': se} res["error_info"] = error response = request.make_response( json.dumps(res), headers={"Access-Control-Allow-Origin": "*"}) return response
def weather_change(self, w=None, currently_active=None): #try: if self._last_current_weather['data'] == {}: if self.current_weather() == {}: return last = self._last_current_weather['data'] if w is None: w = self.current_weather() status_message = status.Status().active_change(currently_active) if self.weather_text(w)[1] != self.weather_text(last)[1]: if self.weather_text(w)[1]: message.send_message( '<a href="https://openweathermap.org/city/4720060"><b>Weather has changed:</b></a>\n<i>' + self.weather_text(w)[0] + '</i>' + status_message) else: message.send_message( '<a href="https://openweathermap.org/city/4720060"><b>Weather has changed:</b></a>\n<i>' + self.weather_text(w)[0] + '</i>' + status_message) elif self.wind_text(w)[1] != self.wind_text(last)[1]: if self.wind_text(w)[1]: message.send_message( '<a href="https://openweathermap.org/city/4720060"><b>Wind has changed:</b></a>\n<i>' + self.wind_text(w)[0] + '</i>' + status_message) else: message.send_message( '<a href="https://openweathermap.org/city/4720060"><b>Wind has changed:</b></a>\n<i>' + self.wind_text(w)[0] + '</i>' + status_message) elif self.weather_text(w)[1] != self.weather_text( last)[1] and self.wind_text(w)[1] != self.wind_text(last)[1]: out = '<a href="https://openweathermap.org/city/4720060"><b>Weather and wind have changed:</b></a><i>\nWeather: ' out += ('✅' if self.weather_text(w)[1] else '❌') out += ' ' + self.weather_text(w)[0] + '\nWind: ' out += ('✅' if self.wind_text(w)[1] else '❌') out += ' ' + self.wind_text(w)[0] + '</i>' message.send_message(out + status_message)
def game_on(): pygame.init() pygame.mixer.init() screen = pygame.display.set_mode([1080, 640]) pygame.display.set_caption("Thunder Game") ship = warship.Warship(screen) but = button.Button(screen) stat = status.Status() sco = score.Score(screen, stat) sounds = sound.Sounds() bullets = pygame.sprite.Group() aliens = pygame.sprite.Group() gf.init_aliens(screen, aliens) booms = [] pygame.mixer.music.load("sound/background.mp3") pygame.mixer.music.set_volume(0.3) pygame.mixer.music.play() while True: gf.check_events(ship, but, stat) gf.check_hit_alien(screen, bullets, aliens, booms, sco) gf.check_hit_warship(ship, aliens, bullets, stat) gf.show_all(screen, ship, bullets, aliens, booms, but, stat, sco)
def run(self): """ The main menu """ logging.debugv("menu/__init__.py->run(self)", []) if not self.c.getSensorID() == "Unknown": if self.c.getLock() == "Enabled": lock.Lock(self.d).run() title = "\\ZbStart\\n\\ZB" subtitle = "What do you want to do today?" title += subtitle choice = self.d.menu(title, choices=[ ("Configure", "Configure this sensor"), ("Manage", "Start/stop sensor functions"), ("Status", "View the status of this sensor"), ("Log", "View the logfile of this sensor"), #("Update", "Update the sensor scripts"), #("Console", "Open a management console"), ("About", "Learn more about the SURFids sensor"), ("Shutdown", "Shutdown the machine"), ("Lock", "Lock the sensor menu"), ], nocancel=1, width=60, colors=1) #cancel if choice[0] == 1: return elif choice[1] == "Configure": config.Config(self.d).run() elif choice[1] == "Manage": manage.Manage(self.d).run() elif choice[1] == "Status": status.Status(self.d).run() elif choice[1] == "Log": log.Log(self.d).run() elif choice[1] == "Console": console.Console(self.d).run() elif choice[1] == "About": about.About(self.d).run() elif choice[1] == "Shutdown": manage.Manage(self.d).shutdown() elif choice[1] == "Lock": lock.Lock(self.d).run() self.run()
def __init__(self): self.status = status.Status() self.formats = formats.Format() self.msg = messaging.Messaging() self.enf2 = enf2.ENF2() self.PC1001 = {"ALL":"allTheTen", "Field":"PCI Unit_Number", "S":self.status.c, "F":self.formats.get_format("AS10"), "MSG":msg.ENF021, "ENF":enf2.ENF021}, self.PCI002 = {"ALL":"allTheTen", "Field":"PCI Unit Name", "S":self.status.c, "F":self.formats.get_format("AS50"), "MSG":msg.ENF021, "ENF":enf2.ENF021} self.PCI003 = {"ALL":"allTheTen", "Field":"PCI Floor Number", "S":self.status.c, "F":self.formats.get_format("AS10"), "MSG":msg.ENF021, "ENF":enf2.ENF021} self.PCI004 = {"ALL":"allTheTen", "Field":"PCI Plot or Street Number", "S":self.status.o, "F":self.formats.get_format("A10"), "MSG":msg.NONENFORCMENT, "ENF":enf2.NONENFORCMENT} self.PCI005 = {"ALL":"allTheTen", "Field":"PCI LC or Street Name", "S":STATUS.o, "F":self.formats.get_format("A50"), "MSG":msg.NONENFORCMENT, "ENF":enf2.NONENFORCMENT} PCI006("allTheTen", "PCI Parish", STATUS.C, FORMAT.A50, MESSAGES.ENF049,new ENF2[] { ENF2.ENF036, ENF2.ENF049 }), PCI007("allTheTen","PCI Suburb", STATUS.O, FORMAT.A50, MESSAGES.NONENFORCMENT,new ENF2[] { ENF2.NONENFORCMENT }), PCI008("allTheTen","PCI Village", STATUS.O, FORMAT.A50, MESSAGES.NONENFORCMENT,new ENF2[] { ENF2.NONENFORCMENT }), PCI009("allTheTen","PCI County or Town", STATUS.C, FORMAT.A50, MESSAGES.ENF036,new ENF2[] { ENF2.ENF036, ENF2.ENF049 }), PCI010("allTheTen","PCI District", STATUS.C, FORMAT.A50, MESSAGES.ENF036, new ENF2[] {ENF2.ENF036, ENF2.ENF049 }), PCI011("allTheTen","PCI Region", STATUS.C, FORMAT.N1, MESSAGES.ENF036, new ENF2[] {ENF2.ENF036, ENF2.ENF054, ENF2.ENF116 }), PCI012("allTheTen", "PCI PO Box Number", STATUS.C, FORMAT.A10,MESSAGES.ENF014, new ENF2[] { ENF2.ENF014 }), PCI013("allTheTen","PCI Post Office Town", STATUS.C, FORMAT.A20, MESSAGES.ENF014,new ENF2[] { ENF2.ENF014 }), PCI014("allTheTen","PCI Country Code", STATUS.M, FORMAT.A2, MESSAGES.ENF014,new ENF2[] { ENF2.ENF065, ENF2.ENF014 }), PCI015("allTheTen","PCI Period At Address", STATUS.M, FORMAT.N3, MESSAGES.ENF014, new ENF2[] { ENF2.ENF014, ENF2.ENF116 }),
def _profile_system(self, checktype = sysmonitor.CHECK_ALL): ''' Profile system and return an exception or an errorcode whether the system is not suitable for measuring. ''' errorcode = 0 if not (self._isprobe or BYPASS_PROFILER): try: if (checktype == sysmonitor.CHECK_ALL): test = sysmonitor.checkall(self._client.profile.upload, self._client.profile.download, self._client.isp.id, ARPING) elif (checktype == sysmonitor.CHECK_MEDIUM): test = sysmonitor.mediumcheck() else: test = sysmonitor.fastcheck() if test != True: raise Exception('Condizioni per effettuare la misura non verificate.') except Exception as e: logger.error('Errore durante la verifica dello stato del sistema: %s' % e) if self._killonerror: self._evaluate_exception(e) else: self._updatestatus(status.Status(status.ERROR, 'Misura in esecuzione ma non corretta. %s Proseguo a misurare.' % e)) errorcode = errors.geterrorcode(e) return errorcode
def refreshSamples(self, *foo): nsmp = self.nobj.current if self.nsmp == nsmp and self.nodeViews and self.nodes and self.count( ) > 2: logging.debug('NO CHANGE in samples number', self.nsmp, nsmp) return False self.nsmp = nsmp self.blockSignals(True) self.clear() if not self.fixedDoc: self.statusView = status.Status(self.server, self.remote, parent=self) self.addTab(self.statusView, 'Status') registry.system_kid_changed.connect(self.system_kid_slot) self.up_isRunning() else: self.statusView = False self.addTab(self.measureView, _('Measure')) if self.remote['devpath'] != 'flash': self.addTab(self.thermalCycleView, _('Thermal Cycle')) else: self.thermalCycleView.hide() self.set_results(self.results) self.refresh_nodes() self.blockSignals(False) return True
def _func_except_handler(): result = {} try: result = func() except Exception, e: result["code"] = status.Status.ERROR result["nessage"] = status.Status().getReason(result["message"]) return result
def reset_response_data(status_code, error_info=None): result = {} result["success"] = status_code result["return_code"] = status.Status().getReason(result["success"]) if error_info: result["error_info"] = error_info result["data"] = {} return result
def startPhase1(self): self.phase = 1 self.main.get(graphics.SwimBackground(self.main)) self.main.status = status.Status(self.main) self.main.get(self.main.status) self.main.get(word.Word(self.main)) self.main.get(graphics.Shower(self.main))
def __init__(self, context, prev, next, install): Gtk.VBox.__init__(self) self.prev = prev self.next = next self.install = install self.context = context intro_card = intro.Intro(self.context) device_card = device.Device(self.context) partition_card = partition.Partition(self.context) timezone_card = timezone.Timezone(self.context) locale_card = locale.Locale(self.context) user_card = user.User(self.context) root_card = root.Root(self.context) finalinfo_card = finalinfo.FinalInfo(self.context) status_card = status.Status(self.context) self.card_names = [ 'intro_card', 'device_card', 'partition_card', 'timezone_card', 'locale_card', 'user_card', 'root_card', 'finalinfo_card', 'status_card' ] self.cards = [ intro_card, device_card, partition_card, timezone_card, locale_card, user_card, root_card, finalinfo_card, status_card ] self.the_stack = Gtk.Stack() self.the_stack.set_hexpand(True) self.the_stack.set_vexpand(True) self.context['the_stack'] = self.the_stack self.pack_start(self.the_stack, True, True, 0) self.set_name('stack') # add the cards to the stack self.the_stack.add_titled(intro_card, 'intro_card', 'Introduction') self.the_stack.add_titled(device_card, 'device_card', 'Device') self.the_stack.add_titled(partition_card, 'partition_card', 'Partition') self.the_stack.add_titled(timezone_card, 'timezone_card', 'Timezone') self.the_stack.add_titled(locale_card, 'locale_card', 'Locale') self.the_stack.add_titled(user_card, 'user_card', 'User') self.the_stack.add_titled(root_card, 'root_card', 'Root') self.the_stack.add_titled(finalinfo_card, 'finalinfo_card', 'Confirmation') self.the_stack.add_titled(status_card, 'status_card', 'Status') self.prev.connect('clicked', self.nav_prev) self.next.connect('clicked', self.nav_next) self.current_card = self.card_names[0] self.current_index = 0 self.prev.set_sensitive(False) self.install.set_sensitive(False)
def httptarget(handler, namespace, command_queue): print 'Starting HTTP server on %s.' % port server = BaseHTTPServer.HTTPServer((host, port), handler) # server.status = status.StatusManager(namespace,command_queue,response_queue) server.status = status.Status() # server.status.start() server.namespace = namespace server.command_queue = command_queue server.serve_forever()
def run_status(self): sys.stdout = self ## sys.stderr = self try: del (sys.modules["status"]) except: ## Yeah, it's a real ugly solution... pass import status status.Status() sys.stdout = sys.__stdout__
def __init__(self): self.body = body.Body() self.panel = panel.Panel(self.body) self.status = status.Status(self.body) self.edgepoint = None self.twinklers = [] self.shots = [] self.paused = False self.target = None self.healmode = False self.clearselections() self.clickat = None
def processAll(self, workers=None): if self._mode == _MODE_R2: processProc = _processR2Procedure imports_dict = self.imports_dict elif self._mode == _MODE_IDA: processProc = _processIDAProcedure imports_dict = None elif self._mode == _MODE_IDB: processProc = _processR2Procedure imports_dict = self.imports_dict else: raise RuntimeError("BinaryInfo.processAll: mode not valid") results = [] def _callback(res): if type(res) == type(""): printerr(" >> " + RED + "Error" + NC + " on function %s, skipped" % res) else: results.append(res) print(" >> Processing all procedures") with status.Status(len(self.procs)) as bar: if workers == 1: count = 0 for proc in self.procs: r = processProc(proc, imports_dict, self.arch) _callback(r) count += 1 bar.update(count) else: if workers == None: pool = mp.Pool(mp.cpu_count()) else: pool = mp.Pool(workers) r = [ pool.apply_async(processProc, args=(proc, imports_dict, self.arch), callback=_callback) for proc in self.procs ] pool.close() while len(results) != len(self.procs): bar.update(len(results)) time.sleep(0.05) self.data["procs"] = results return self.data
def main(postgres_cursor, img_dir, model_path): print('loading model') sess = tf.Session() model_filename = os.path.join(model_path, 'classify_image_graph_def.pb') with gfile.FastGFile(model_filename, 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) bottleneck_tensor, jpeg_data_tensor = (tf.import_graph_def( graph_def, name='', return_elements=[BOTTLENECK_TENSOR_NAME, JPEG_DATA_TENSOR_NAME])) classes = json.load(open(CLASSES_PATH)) info = [] image_vecs = [] stat = status.Status(qps_field='class') for wikipedia_id, description, image in classes: stat.count('class').report() res = fetch_image(image, img_dir) if not res: res = fetch_image_for_wikipedia_id(wikipedia_id, img_dir, stat, postgres_cursor) if not res: stat.count('no-image') continue else: stat.count('wikipedia') else: stat.count('direct') img_path, image_url = res image_data = gfile.FastGFile(img_path, 'rb').read() try: bottleneck_values = sess.run(bottleneck_tensor, {jpeg_data_tensor: image_data}) bottleneck_values = np.squeeze(bottleneck_values) except InvalidArgumentError: stat.count('tf-error') continue image_vecs.append(bottleneck_values) info.append({ 'wiki_name': wikipedia_id, 'img_path': img_path, 'image_url': image_url, 'description': description }) with open(INFO_PATH, 'wb') as fout: pickle.dump((info, np.array(image_vecs)), fout)
def parse_status(self, lines): # A list of status objects. activity = [] # Keep a list of seen times so we can avoid duplicates in the history seen_times = set() for line in lines: time, fields = line.split("|") # Only add new times, preferring earlier records in the file. This is probably not optimal since later records seem to be more likely to be LATs, but oh well gotta break a few algorithmic contraints to make a BILLION dollars. if time not in seen_times: seen_times.add(time) status_obj = status.Status(int(float(time)), fields) activity.append(status_obj) return activity
def ratchet_test(): """Test Ratchet functionality.""" class P(object): X = 'X' Y = 'Y' Z = 'Z' status.P = P status.IMPLICATIONS = {} status_export_path = tempfile.mkdtemp() try: x = y = z = 0 r = ratchet.Ratchet('test ratchet', [ ratchet.Condition('x', lambda: x, 0.1), ratchet.Condition('y', lambda: y, 0.1), ratchet.Condition('z', lambda: z, 0.1), ], status.Status('test ratchet', status_export_path)) x = y = 1 # Test that timeouts are not just summed, but start whenever the previous # step completed. wvtest.WVPASSEQ(r._current_step, 0) # pylint: disable=protected-access wvtest.WVFAIL(os.path.isfile(os.path.join(status_export_path, 'X'))) wvtest.WVFAIL(os.path.isfile(os.path.join(status_export_path, 'Y'))) wvtest.WVFAIL(os.path.isfile(os.path.join(status_export_path, 'Z'))) r.start() wvtest.WVPASS(os.path.isfile(os.path.join(status_export_path, 'X'))) wvtest.WVFAIL(os.path.isfile(os.path.join(status_export_path, 'Y'))) wvtest.WVFAIL(os.path.isfile(os.path.join(status_export_path, 'Z'))) time.sleep(0.05) wvtest.WVFAIL(r.check()) wvtest.WVPASSEQ(r._current_step, 2) # pylint: disable=protected-access wvtest.WVPASS(os.path.isfile(os.path.join(status_export_path, 'X'))) wvtest.WVPASS(os.path.isfile(os.path.join(status_export_path, 'Y'))) wvtest.WVPASS(os.path.isfile(os.path.join(status_export_path, 'Z'))) wvtest.WVFAIL(r.check()) wvtest.WVPASSEQ(r._current_step, 2) # pylint: disable=protected-access time.sleep(0.1) wvtest.WVEXCEPT(ratchet.TimeoutException, r.check) x = y = z = 1 r.start() wvtest.WVPASS(r.check()) finally: shutil.rmtree(status_export_path)
def __init__(self): self._options = {} #Add menu classes self._optionLookup = {} #Add/order your menu option here self._options = [ addSubproject.AddSubproject(), bundle.Bundle(), bundle.Unbundle(), branches.Branches(), status.Status(), stash.Stash(), checkout.Checkout(), push.Push(), pull.Pull(), commit.Commit(), publish.Publish(), clone.Clone(), config.Config(), grapeConfig.WriteConfig(), foreach.ForEach(), merge.Merge(), mergeDevelop.MergeDevelop(), mergeRemote.MergeRemote(), deleteBranch.DeleteBranch(), newWorkingTree.NewWorkingTree(), resolveConflicts.ResolveConflicts(), review.Review(), test.Test(), updateLocal.UpdateLocal(), updateSubproject.UpdateSubproject(), hooks.InstallHooks(), hooks.RunHook(), updateView.UpdateView(), version.Version(), walkthrough.Walkthrough(), quit.Quit() ] #Add/order the menu sections here self._sections = [ 'Getting Started', 'Code Reviews', 'Workspace', 'Merge', 'Gitflow Tasks', 'Hooks', 'Patches', 'Project Management', 'Other' ]
def __init__(self, index): self.index = index # units / second self.velocity = 400 self.baseVelocity = 0 # units / second / second self.acceleration = 400 self.deceleration = 400 # self.highLimit = 40000 self.lowLimit = -40000 # self.units = "counts" self.resolution = 1.0 # self.moveStartTime = None self.abortTime = None # self.lastPosition = 0 self.currentPosition = 0 self.currentDisplacement = 0 self.targetPosition = 0 self.direction = 1 self.moveVelocity = self.velocity # Move info self.accelDuration = 0.0 self.accelDistance = 0 self.decelDuration = 0.0 self.decelDistance = 0 self.moveDistance = 0 self.constVelDuration = 0.0 self.decelStartTime = 0.0 self.moveDuration = 0.0 # self.enforceLimits = False # self.status = status.Status()
def __init__(self, args): self.properties = {'paths': {}} self.modified = False # determine project root directory # (has to use intermediate variable because that's used later) directory = script.absolute_path(args['directory']) self.properties['paths']['root'] = directory info('Opening project {}'.format(self.properties['paths']['root'])) # check if we're in a VCS repository and create VCS object self.vcs = vcs.open(self) # set/determine information on the project directory structure. # If the file project/properties.json is present it is parsed, # otherwise default values are used. self.properties_file = os.path.join( self['paths']['root'], args['properties_file'] ) if args['properties_file'] else os.path.join( self.properties['paths']['root'], 'project', 'properties.json') if os.path.isfile(self.properties_file): try: self.read_properties_from_json() # reinstall root directory (as this is not saved in the json file) self['paths']['root'] = directory except Exception as e: warn("{}\n" + "Setting project structure to default values.".format(e)) self.set_defaults() else: self.set_defaults() self.status = status.Status(self)
def __init__(self): self.status = status.Status() self.formats = formats.Format() self.msg = messaging.Messaging() self.enf2 = enf2.ENF2() self.PC1001 = {"ALL":"allTheTen", "Field":"PCI Unit_Number", "S":self.status.c, "F":self.formats.get_format("AS10"), "MSG":msg.ENF021, "ENF":enf2.ENF021}, self.PCI002 = {"ALL":"allTheTen", "Field":"PCI Unit Name", "S":self.status.c, "F":self.formats.get_format("AS50"), "MSG":self.msg.ENF021, "ENF":self.enf2.ENF021} self.PCI003 = {"ALL":"allTheTen", "Field":"PCI Floor Number", "S":self.status.c, "F":self.formats.get_format("AS10"), "MSG":self.msg.ENF021, "ENF":self.enf2.ENF021} self.PCI004 = {"ALL":"allTheTen", "Field":"PCI Plot or Street Number", "S":self.status.o, "F":self.formats.get_format("A10"), "MSG":self.msg.NONENFORCMENT, "ENF":self.enf2.NONENFORCMENT} self.PCI005 = {"ALL":"allTheTen", "Field":"PCI LC or Street Name", "S":self.status.o, "F":self.formats.get_format("A50"), "MSG":self.msg.NONENFORCMENT, "ENF":self.enf2.NONENFORCMENT} self.PCI006 = {"ALL":"allTheTen", "Field":"PCI Parish", "S":self.status.c, "F":self.formats.get_format("A50"), "MSG":self.msg.ENF049 , "ENF":{"ENF2.ENF036":"ENF2.ENF036", "ENF2.ENF049":"ENF2.ENF049" }} self.PCI007 = {"ALL":"allTheTen", "Field":"PCI Suburb", "S":self.status.o, "F":self.formats.get_format("A50"), "MSG":msg.NONENFORCMENT ,"ENF":self.enf2.NONENFORCMENT} self.PCI008 = {"ALL":"allTheTen", "Field":"PCI Village", "S":self.status.o, "F":self.formats.get_format("A50"), "MSG":self.msg.NONENFORCMENT , "ENF":self.enf2.NONENFORCMENT} self.PCI009= {"ALL":"allTheTen", "Field":"PCI County or Town", "S":self.status.c, "F":self.formats.get_format("A50"), "MSG":self.msg.NONENFORCMENT, "ENF":{"ENF2.ENF036":ENF2.ENF036, "ENF2.ENF049":ENF2.ENF049 }} self.PCI010={"ALL":"allTheTen", "Field":"PCI District", "S":self.status.c, "F":self.formats.get_format("A50"), "MSG":self.msg.ENF036, {"ENF2.ENF036":ENF2.ENF036, "ENF2.ENF049":ENF2.ENF049 }} self.PCI011 = {"ALL":"allTheTen", "Field":"PCI Region", "S":self.status.c, "F":self.formats.get_format("N1"), "MSG":self.msg.ENF036, {"ENF2.ENF036":"ENF2.ENF036", "ENF2.ENF054":ENF2.ENF054, "ENF2.ENF116":"ENF2.ENF116" }} self.PCI012 = {"ALL":"allTheTen", "Field":"PCI PO Box Number", "S":self.status.c, "F":self.formats.get_format("A10"), "MSG":self.msg.ENF014, "ENF":self.enf2.ENF014} self.PCI013 = {"ALL":"allTheTen", "Field":"PCI Post Office Town", "S":self.status.c, "F":self.formats.get_format("A20"), "MSG":self.msg.ENF014 ,"ENF":self.enf2.ENF014} self.PCI014 = {"ALL":"allTheTen", "Field":"PCI Country Code","S":self.status.m, "F":self.formats.get_format("A2"), "MSG":self.msg.ENF014 ,"ENF":self.enf2.ENF014 } self.PCI015 = {"Field":"allTheTen", "Field":"PCI Period At Address", "S":self.status.m, "F":self.formats.get_format("N3"), "MSG":self.msg.ENF014, "ENF2.ENF014":"ENF2.ENF014", "ENF2.ENF116":"ENF2.ENF116" } self.PCI016 = {"ALL":"allTheTen", "Field":"PCI Flag of Ownership", "S":self.status.m, "F":self.formats.get_format("A1"), "MSG":self.msg.ENF014, "ENF":self.enf2.ENF084 }, self.PCI017 = {"ALL":"allTheTen", "Field":"PCI Primary Number Country Dialling Code", "S":self.status.m, "F":self.formats.get_format("N5"), "MSG":self.msg.ENF056, {"ENF2.ENF056":"ENF2.ENF056", "ENF2.ENF116":"ENF2.ENF116" }} self.PCI018 = {"ALL":"allTheTen", "Field":"PCI Primary Number Telephone Number", "S":self.status.m, "F":self.formats.get_format("N10"), "MSG":self.msg.ENF116, "ENF":self.enf2.ENF116 } self.PCI019 = {"ALL":"allTheTen", "Field":"PCI Other Number Country Dialling Code","S":self.status.c, "F":self.formats.get_format("N5"), "MSG":self.msg.ENF116, {"ENF2.ENF116":"ENF2.ENF116", "ENF2.ENF056""ENF2.ENF056" }} self.PCI020 = {"ALL":"allTheTen", "Field":"PCI Other Number Telephone Number", "S":self.status.c, "F":self.formats.get_format("N10"), "MSG":self.msg.ENF116, "ENF":self.enf2.ENF116 } self.PCI021 ={"ALL":"allTheTen", "Field":"PCI Mobile Number Country Dialling Code", "S":self.status.c, "F":self.formats.get_format("N5"), "MSG":self.msg.ENF056, {"ENF2.ENF116":"ENF2.ENF116", "ENF2.ENF056":"ENF2.ENF056" }} self.PCI022={"ALL":"allTheTen", "Field":"PCI Mobile Number Telephone Number", "S":self.status.c, "F":self.formats.get_format("N10"), "MSG":self.msg.ENF116, "ENF":self.enf2.ENF116 } self.PCI023 = {"ALL":"allTheTen", "Field":"PCI Facsimile Country Dialling Code", "S":self.status.c, "F":self.formats.get_format("N5"), "MSG":self.msg.ENF116, {"ENF2.ENF116":"ENF2.ENF116", "ENF2.ENF056":"ENF2.ENF056"}} self.PCI024 = {"ALL":"allTheTen", "Field":"PCI Facsimile Number", "S":self.status.c, "F":self.formats.get_format("N10") ,"MSG":self.msg.ENF116, "ENF":self.enf2.ENF116 } self.PCI025 = {"ALL":"allTheTen", "Field":"PCI Email Address", "S":self.status.c, "F":self.formats.get_format("AS50"), "MSG":self.msg.ENF129, "ENF":self.enf2.ENF129 } self.PCI026 = {"ALL":"allTheTen", "Field":"PCI Website","S":self.status.c, "F":self.formats.get_format("AS50"), "MSG":self.msg.ENF129, "ENF":self.enf2.ENF129 } self.PI001 = {"dataset":"PI", "Field":"PI Identification Code", "S":self.status.m, "F":self.formats.get_format("A6"), "MSG":self.msg.ENF068, "ENF":self.enf2.ENF068 }, self.PI002 = {"dataset":"PI", "Field":"Institution Type", "S":self.status.m, "F":self.formats.get_format("A3"), "MSG":self.msg.ENF069, "ENF":self.enf2.ENF069 } self.PI003 = {"dataset":"PI", "Field":"Institution Name","S":self.status.m, "F":self.formats.get_format("AS100"), "MSG":self.msg.ENF129, {"ENF2.ENF014":"ENF2.ENF014", "ENF2.ENF129":"ENF2.ENF129" }} self.PI004 = {"dataset":"PI", "Field":"License Issuing Date", "S":self.status.m, "F":self.formats.get_format("N8"), "MSG":self.msg.ENF007, {"ENF2.ENF014":"ENF2.ENF014" ,"ENF2.ENF007":"ENF2.ENF007"}} self.allTheTen = "allTheTen"; self.dataset; self.data_filed; '''
def __init__(self): self.status = status.Status() self.display = display.Display() self.play = 0
import inference import status import numpy as np import time import logging current_timestamp = time.time() home_status = status.Status(current_timestamp) print (f'{status}\n\n' ) # create an inference class_array = np.asarray([3]) prob_array = np.asarray([0.7207128]) bbox_array = np.asarray([[0.5771041, 0.0, 0.9947256, 0.24670777]]) inf = inference.ModelInference(class_array, prob_array, bbox_array) # create a detection camera_id = 2 region_id = 3 new_objects = 1 dup_objects = 0 det = inference.RegionDetection(camera_id, region_id, new_objects, dup_objects, inf) print (f'DETECTION:\n {det}') # update the status with the detection home_status.update_from_detection(det) print (f'{status}\n\n' )
#!/usr/bin/python import sys import signal sys.path.append("../") sys.path.append("./") import pktdata from websocket import create_connection, ABNF import time import status stat = status.Status() ws = create_connection("ws://localhost:8888/ws") def exit_gracefully(signum, frame): print "Exit Gracefully, Ctrl+C pressed" ws.close() sys.exit(0) signal.signal(signal.SIGINT, exit_gracefully) print "Sending packet" for i in range(10): #print pktdata.test_data pkt = stat.struct.pack(*pktdata.test_data) ws.send(pkt, ABNF.OPCODE_BINARY) print "Sent %d" % i print "Receiving..." #result = ws.recv()
def daily_update_message(closures, tfrs, weather) -> str: db = database.Database() flight = (Weather().weather_text(weather)[1] and Weather().wind_text(weather)[1] and closures[0] and tfrs[0]) staticfire = closures[0] if datetime.date.today().weekday() > 4 and not flight: print('weekend and nothing possible') return '' flightStr = 'yes' if flight else 'no' staticStr = 'yes' if staticfire else 'no' #Header & Roadclosure out = '<b>𝗗𝗮𝗶𝗹𝘆 𝗙𝗹𝗶𝗴𝗵𝘁 𝗦𝘁𝗮𝘁𝘂𝘀</b> <i>[flight: ' + flightStr + '| static: ' + staticStr + ']</i>\nCurrent Time UTC: ' + db.datetime_to_string( datetime.datetime.utcnow() ) + ' local: ' + db.datetime_to_local_string( datetime.datetime.utcnow() ) + '\n<a href="https://www.cameroncounty.us/spacex/"><b>Road Closure:</b></a>' if closures[0]: out += '✅\n' for x in closures[1:]: out += 'from ' + db.datetime_to_string( x[0]) + ' to ' + db.datetime_to_string(x[1]) + ' (UTC)' out += '\n<i>(local: ' + db.datetime_to_local_string( x[0]) + ' to ' + db.datetime_to_local_string(x[1]) + ')</i>\n' else: out += '❌\nnothing scheduled!\n' #TFR out += '<a href="https://tfr.faa.gov/tfr_map_ims/html/cc/scale7/tile_33_61.html"><b>TFR:</b></a>' if tfrs[0]: out += '✅\n' else: out += '❌\n' if len(tfrs) != 1: out += '(max alt. needs to be unlimited for flight)\n' unlimited, limited = False, False for x in tfrs[1:]: if x[3]: unlimited = True out += 'from ' + db.datetime_to_string( x[0]) + ' to ' + db.datetime_to_string( x[1]) + ' (max alt.: unlimited)\n' out += '<i>(local from ' + db.datetime_to_local_string( x[0]) + ' to ' + db.datetime_to_local_string(x[1]) + ')</i>\n' else: limited = True if unlimited and limited: out += '-----\n' for x in tfrs[1:]: if not x[3]: out += '<i>from ' + db.datetime_to_string( x[0]) + ' to ' + db.datetime_to_string( x[1]) + ' (max alt.: ' + str(x[2]) + ' ft)</i>\n' #Weather out += '<a href="https://openweathermap.org/city/4720060"><b>Weather today:</b></a>' if Weather().weather_text(weather)[1]: out += '✅\n' + Weather().weather_text(weather)[0] + '\n' else: out += '❌\n' + Weather().weather_text(weather)[0] + '\n' #Wind out += '<a href="https://openweathermap.org/city/4720060"><b>Wind:</b></a>' if Weather().wind_text(weather)[1]: out += '✅\n' + Weather().wind_text(weather)[0] + '\n' else: out += '❌\n' + Weather().wind_text(weather)[0] + '\n' #Flight Message out += status.Status().daily_status(weather) out += '<i>(We will keep you updated if anything changes!)</i>' if not (flight or staticfire): #daily only if anything is possible out = '' return out
def test_status(): export_path_s = tempfile.mkdtemp() export_path_t = tempfile.mkdtemp() export_path_st = tempfile.mkdtemp() try: s = status.Status('s', export_path_s) t = status.Status('t', export_path_t) st = status.CompositeStatus('s_or t', export_path_st, [s, t]) # Sanity check that there are no contradictions. for p, (want_true, want_false) in status.IMPLICATIONS.iteritems(): setattr(s, p.lower(), True) wvtest.WVPASS(has_file(s, p)) for wt in want_true: wvtest.WVPASS(has_file(s, wt)) for wf in want_false: wvtest.WVFAIL(has_file(s, wf)) def check_exported(check_s, check_t, filename): wvtest.WVPASSEQ(check_s, has_file(s, filename)) wvtest.WVPASSEQ(check_t, has_file(t, filename)) wvtest.WVPASSEQ(check_s or check_t, has_file(st, filename)) s.trying_wlan = True t.trying_wlan = False check_exported(True, False, status.P.TRYING_WLAN) check_exported(False, False, status.P.CONNECTED_TO_WLAN) s.connected_to_open = True check_exported(True, False, status.P.CONNECTED_TO_OPEN) check_exported(False, False, status.P.CONNECTED_TO_WLAN) s.connected_to_wlan = True t.trying_wlan = True check_exported(True, False, status.P.CONNECTED_TO_WLAN) check_exported(True, False, status.P.HAVE_WORKING_CONFIG) check_exported(False, False, status.P.CONNECTED_TO_OPEN) check_exported(False, True, status.P.TRYING_WLAN) check_exported(False, False, status.P.TRYING_OPEN) s.can_reach_acs = True s.can_reach_internet = True check_exported(True, False, status.P.CAN_REACH_ACS) check_exported(True, False, status.P.COULD_REACH_ACS) check_exported(True, False, status.P.CAN_REACH_INTERNET) check_exported(False, False, status.P.PROVISIONING_FAILED) # These should not have changed check_exported(True, False, status.P.CONNECTED_TO_WLAN) check_exported(True, False, status.P.HAVE_WORKING_CONFIG) check_exported(False, False, status.P.CONNECTED_TO_OPEN) check_exported(False, True, status.P.TRYING_WLAN) check_exported(False, False, status.P.TRYING_OPEN) # Test provisioning statuses. s.waiting_for_dhcp = True check_exported(False, True, status.P.TRYING_WLAN) check_exported(False, False, status.P.TRYING_OPEN) check_exported(False, False, status.P.CONNECTED_TO_WLAN) check_exported(True, False, status.P.CONNECTED_TO_OPEN) check_exported(True, False, status.P.WAITING_FOR_PROVISIONING) check_exported(True, False, status.P.WAITING_FOR_DHCP) s.acs_connection_check = True check_exported(False, False, status.P.WAITING_FOR_DHCP) check_exported(True, False, status.P.ACS_CONNECTION_CHECK) s.waiting_for_cwmp_wakeup = True check_exported(False, False, status.P.ACS_CONNECTION_CHECK) check_exported(True, False, status.P.WAITING_FOR_CWMP_WAKEUP) s.waiting_for_acs_session = True check_exported(False, False, status.P.WAITING_FOR_DHCP) check_exported(False, False, status.P.WAITING_FOR_CWMP_WAKEUP) check_exported(True, False, status.P.WAITING_FOR_ACS_SESSION) s.provisioning_completed = True check_exported(False, False, status.P.WAITING_FOR_PROVISIONING) check_exported(False, False, status.P.WAITING_FOR_DHCP) check_exported(False, False, status.P.ACS_CONNECTION_CHECK) check_exported(False, False, status.P.WAITING_FOR_CWMP_WAKEUP) check_exported(False, False, status.P.WAITING_FOR_CWMP_WAKEUP) finally: shutil.rmtree(export_path_s) shutil.rmtree(export_path_t) shutil.rmtree(export_path_st)
import pygame if __name__ == '__main__': pygame.init() pygame.display.set_caption('Minesweeper') screen = pygame.display.set_mode((298, 377)) clock = pygame.time.Clock() game = create_game() # prepare sprites groups field = field.Field((18, 98)) bombs_counter = counter.RedCounter((26, 27)) bombs_counter.update(10) secs_counter = counter.RedCounter((200, 27)) statuses = pygame.sprite.Group() status = status.Status(statuses, (126, 27)) # game loop fin = False clamped = set() while not fin: for event in pygame.event.get(): if event.type == pygame.QUIT or event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: pygame.quit() fin = True break if event.type == pygame.MOUSEBUTTONDOWN: clamped.add(event.button) if event.type == pygame.MOUSEBUTTONUP: x, y = event.pos if x > 126 and x < 173 and y > 26 and y < 73:
self.printSmall("press [r] to return to main menu", 140, 320) self.saveScore() if keys[pygame.K_r]: self.state = STATE_MENU_MAIN elif self.state == STATE_SURE_TO_MENU: self.printBig("Sure you wanna go to main menu? (Y/N)", 120, 200) if keys[pygame.K_y]: self.state = STATE_MENU_MAIN elif keys[pygame.K_n]: self.state = self.state_previous elif self.state == STATE_SURE_TO_QUIT: self.printBig("Sure you wanna quit? (Y/N)", 210, 200) if keys[pygame.K_y]: self.endGame() elif keys[pygame.K_n]: self.state = self.state_previous elif self.state == STATE_OUTRO: self.outro() pygame.display.flip() # Main stats = status.Status() game = Game() game.loop() pygame.quit()