def read_db_for_shows(): '''Read show_db SQLite database and populate show list''' try: db = sqlite3.connect('data/show_db.db') cur = db.cursor() cur.execute("PRAGMA foreign_keys=ON") # Fetch some data, using the cursor. This returns another cursor object # that can be iterated over for row in cur.execute('select * from show'): #ui.message(row) update_ind = g.BLANK show = Show(row[1], row[2], row[3], update_ind) show.set_id(row[0]) g.show_list.append(show) # ui.message('************* Shows **************') # ui.message(g.show_list) # ui.message('') except sqlite3.Error as e: # As we are reading, no changes to roll back print('Error reading from database', e) logging.error('Database error {}'.format(e)) traceback.print_exc() finally: db.close()
def run_episode(drones=DRONES, cars=CARS, go='True'): print(drones, cars, go) agent = Agent() env = Environment(DRONES, CARS) while not env.is_done(): agent.step(env) if go: Show.run(env)
def searchId(self): for i in self.results.children(): if (isinstance(i, Ui_Result)): i.deleteLater() if (self.idSearch.text()): result = Show(self.idSearch.text()) data = {'id': result.id, 'title': {'english': result.data["title"]["english"], 'romaji': result.data["title"]["romaji"]}, 'seasonYear': result.data["seasonYear"], 'coverImage': {'large': result.getCoverUrl()}} widget = Ui_Result(data, self.results) self.resultLayout.addWidget(widget)
def parse(string, season=None): prepared_string = get_prepared_string(string) extension = get_extension(prepared_string) sections = break_down_filename(prepared_string) name, episode = get_show_name_and_episode(sections[0]) group = "" encoding = "" version = get_version(prepared_string) for item in sections[1:]: if is_crc(item): pass elif is_group_name(item): group = item elif is_details(item): encoding = get_resolution(item) if episode: if season: return Show(string, name, extension, group, episode, encoding, season, version=version) else: return Show(string, name, extension, group, episode, encoding, 1, version=version) else: return Show(string, name, extension, group, encoding=encoding, version=version) # test = "[ILA]_Aim_for_the_Ace!_-_05.avi" # test = "Senki zesshou symphyogear.mkv" # test = "Senki zesshou symphyogear - [v2][BD 720p AAC] [EB80A8D7].mkv" # # # s = parse(test) # # print(s.version)
def make_show_objects(data): for i in range(0, len(data)): artist = find_or_create_artist(data[i]["artist"]["name"]) date = data[i]["eventDate"] venue = data[i]["venue"]["name"] location = data[i]["venue"]["city"]["name"] + ", " + data[i]["venue"][ "city"]["state"] # setlist = data[i]["sets"] setlist = [] song_list = data[i]["sets"]["set"][0]["song"] for index in range(0, len(song_list)): setlist.append(song_list[index]["name"]) Show(artist, date, venue, location, setlist) return Show.all()
def main(): dt = 0.0001 # the unit time to calculate Nsteps = 20 # steps to refresh the screen gyro = Gyroscope() show = Show() # create the screen to show the movement of gyroscope control = Control(gyro) # create a screen to control gyroscope while True: rate(100) # refresh the screen 100 times one second for i in range(Nsteps): gyro.go(dt) # let the gyroscope go x, y, z = gyro.GetPos() angle = gyro.GetRotationVel() * dt * Nsteps show.update(x, y, z, angle) # update the position and angle of the gyroscope control.ShowEnergy() # show total energy of gyroscope
def get_all_shows(): print("Connecting to database...") conn = create_connection(constants.DB_PATH) print("Successfully connected.") print("Selecting all shows..") rows = select_all_shows(conn) return [Show(n) for n in rows]
def getContent(self, category='all', subCategory=None): assert category in self.categories.keys(), \ "category must be one of the following: %s" % ", ".join(self.categories.keys()) if subCategory: subCategory = str(subCategory) subCategories = self.getSubCategories(category) assert (subCategory == None and subCategories == None) or (subCategory in subCategories.keys()), \ "subCategory must be one of the following: %s. use method getSubCategories() to get key/title" \ " pairs." % ", ".join(subCategories.keys()) if subCategory == None: container = self.server.query("/library/sections/%d/%s" % (self.key, category)) else: container = self.server.query("/library/sections/%d/%s/%s" % (self.key, category, subCategory)) content = [] for e in container: if not 'type' in e.attrib: continue type_ = e.attrib['type'] if type_ == 'movie': # append movie obj = Movie(e, self.server) if type_ == 'show': # append show obj = Show(e, self.server) if type_ == 'episode': obj = Episode(e, self.server) content.append(obj) return content
def scrap_shows_url(domain: str) -> List[Show]: result = [] soup = __get_soup__(domain + "/shows") for show in soup.find_all(href=__is_show__): result.append(Show(show['title'], "", domain + show['href'], "")) return result
def begin_show(quiz): print("Please choose live stream chat provider: ") if present_menu_get_response(["Twitch"]) == 1: username = input("Enter username: "******"Enter Oauth key: ") question_regex = quiz.question_regex key_regex = input( "Please enter user one-time-key regex (usually 10 digits): ") chat_provider = TwitchChat(username, key, "#" + username, question_regex, key_regex) key_path = input( "Please enter the Cloud Firestore document path for this show\'s keys: " ) show = Show(quiz, chat_provider, key_path) master_gui = tk.Tk() master_gui.title("VQM") master_gui.geometry("800x600") gui = OperatorGUI(master_gui, show) gui.pack() master_gui.mainloop()
def main(): atexit.register(killall) args = parse_args() setup_logging(args) # read tool config config = DFSConfig() # setup show show = Show(config, args.show_name) if not show: print('no such show %s', args.show_name) sys.exit(1) # setup stage stage = Stage(show, args.stage_name) if not stage: print('could not load or create stage %s', args.stage_name) sys.exit(1) # setup joystick joy = xbox.Joystick(debug=args.debug, config=config.joystick) if args.check_mode: sys.exit(0) handler = DmxHandler(config, show, stage, joy) # setup data handler, this is our callback loop # as DMX data comes in constantly wrapper = ClientWrapper() rx = wrapper.Client() rx.RegisterUniverse(config.input.universe, rx.REGISTER, handler.handle) wrapper.Run()
def parse(html, thetime): list = ShowList() for elem in html.cssselect("td.starttime"): hour, minute = elem.text.split(":") hour = int(hour) minute = int(minute) time = cet.localize( thetime.replace(hour=hour, minute=minute, tzinfo=None), False) if hour < 5: time = cet.normalize(time + timedelta(days=1)) elem = elem.getnext() title = elem.cssselect("h5 a")[0].text episodetitle = elem.cssselect( "span.episodetitle, span.subtitle") if episodetitle: subtitle = episodetitle[0].text else: subtitle = "" genre = elem.cssselect("span.genre")[0].text list.append(Show(time, title, subtitle, genre)) return list
def index(request, menu, conn=None, url=None, **kwargs): """ This override omeroweb.webclient.load_template to support custom template base_mapr.html """ try: value = get_unicode_or_default(request, 'value', None) query = get_bool_or_default(request, 'query', False) if _get_case_sensitive(mapr_settings, menu): case_sensitive = get_bool_or_default( request, 'case_sensitive', False) else: case_sensitive = False except ValueError: logger.error(traceback.format_exc()) return HttpResponseBadRequest('Invalid parameter value') kwargs['show'] = Show(conn=conn, request=request, menu=menu, value=value) kwargs['load_template_url'] = reverse(viewname="maprindex_%s" % menu) kwargs['template'] = "mapr/base_mapr.html" context = _webclient_load_template(request, menu, conn=conn, url=url, **kwargs) context['active_user'] = context['active_user'] or {'id': -1} context['mapr_conf'] = { 'menu': menu, 'menu_all': mapr_settings.CONFIG[menu]['all'], 'menu_default': mapr_settings.CONFIG[menu]['default'], 'case_sensitive': _get_case_sensitive(mapr_settings, menu)} context['map_ctx'] = \ {'label': menu, 'value': value or "", 'query': query or "", 'case_sensitive': case_sensitive or ""} context['template'] = "mapr/base_mapr.html" return context
def log(self): in_text = self.entered.get('1.0', 'end') new_text, changes, _, _ = Processor.process_text( in_text, 1, META['old_new_delimiters'][META['current_delimiters_text']]) s = Show(self.top, changes)
def test_nulls(self): df = pd.DataFrame({'col1': [11, 2, 3, 4, np.nan, np.nan], 'col2': [8, 9, 10, 11, 12, 13], 'col3': [3, 2, 1, 5, 6, 3]}) res = Show().nulls(df).equals(pd.DataFrame( {'Nulls': [2, 0, 0]}, index=['col1', 'col2', 'col3'])) self.assertEqual(res, True)
def __init__(self, el): self.key = el.get('librarySectionID') self.rating_key = el.get('ratingKey') self.title = el.get('librarySectionTitle') self.thumb = el.get('thumb') self.size = el.get('size') self.shows = [Show(d) for d in el.finall('Directory')]
def get_shows(self, args): if len(args) == 0 or args[0] == '*': filenames = glob.glob(config.shows_dir + '/*.json') else: filenames = [ config.shows_dir + '/' + name + '.json' for name in args ] for filename in filenames: show = Show.from_file(filename) if show: yield show
def run(queue): global NUM_PIXELS NUM_PIXELS = 100 LOOP_TIME = 4 # in ms # Dynamically import all effects for (_, mod_name, _) in pkgutil.iter_modules([Path(__file__).parent / "effects"]): import_module('effects.' + mod_name, package=__name__) global all_effects all_effects = { a.__module__ + '.' + a.__name__: a for a in Effect.__subclasses__() } print("Listing all effects: ") print(all_effects) global currentEffect currentEffect = all_effects["effects.defaultEffects.DefaultEffect"]() # Initialize neopixel or simulator # Pixels = neopixel.NeoPixel(pixel_pin, NUM_PIXELS, brightness=0.2, auto_write=False, pixel_order=ORDER) global pixels pixels = Simulator(NUM_PIXELS) class PlaybackMode(enum.Enum): PASSIVE = 0 SYNCED = 1 RENDERED = 2 mode = PlaybackMode.SYNCED LOOP_TIME /= 1000 # convert from ms to s for time.sleep() function prevTime = time.time() currentShow = Show() currentShow.start(pixels, NUM_PIXELS) time.sleep(LOOP_TIME) show = Show() while True: msg = None if (not queue.empty()): msg = queue.get() prcoessMessage(msg) #TODO: switch statement through possible types of events, process event data and take action based on it currentTime = time.time() ms_later = (currentTime - prevTime) * 1000 prevTime = currentTime currentShow.render(pixels, NUM_PIXELS, ms_later) pixels.show() time.sleep(LOOP_TIME)
def __init__(self, autoplay=False, save_rnn=False): ''' 决定行列数 ... ''' self.rows_ = 20 self.cols_ = 14 self.factory = ShapeFactory() self.over_ = False self.state_ = 0 self.shapes_ = 0 self.curr_level_ = START_LEVEL self.eliminate_rows_ = 10 * self.curr_level_ # :) self.level_intervals_ = [ 1.0, 0.75, 0.6, 0.55, 0.5, 0.475, 0.450, 0.4, 0.375, 0.35, 0.33, 0.3, 0.25, 0.2, 0.1 ] # self.data_ = [[0 for i in range(self.cols_)] for i in range(self.rows_)] # 一个二维数组标识当前数据 ... self.shape_ = None self.quit_ = False self.pause_ = False self.show_ = Show() self.auto_ = autoplay self.reset_cnt_ = 0 if self.auto_: self.blurred_ = False if not AUTO_USING_RULE: from inference_rnn import Inference self.pred_ = Inference(epoch=EPOCH) # 加载 rnn 模型进行预测 ... #准备记录键盘操作序列 self.save_rnn_ = save_rnn if save_rnn: try: import os os.mkdir(curr_path + '/rnn_{}'.format(MODE)) except: pass self.rnn_fname_prefix = curr_path + '/rnn_{}'.format( MODE) + '/' + time.strftime('%j%H%M-', time.localtime()) self.rnn_ops_ = [] # 记录操作序列,[(np(data_), key), ... ] # np(data_) 为当前 self.data_ 的np数组,key 为对当前的操作 if MODE == 'online' and autoplay: self.prepare_online_train()
def make_show_objects(data): for item in data: artist = find_or_create_artist(item['artist']['name']) date = item['eventDate'] venue = item['venue']['name'] location = item['venue']['city']['name'] + ", " + item['venue'][ 'city']['state'] setlist = [song['name'] for song in item['sets']['set'][0]['song']] show_obj = Show(artist, date, venue, location, setlist) return show_obj
def getMediaObject(self): media = False if self.type == "episode": media = Episode(self.tag, self.server) elif self.type == "movie": media = Movie(self.tag, self.server) elif self.type == "show": media = Show(self.tag, self.server) elif self.type == "season": media = Season(self.tag, self.server) return media
def make_show_objects(data): for set in data: artiste = find_or_create_artist(set['artist']['name']) date = set['eventDate'] venue = set['venue']['name'] location = set['venue']['city']['name'] + ", " + set['venue']['city'][ 'state'] setlist = [] for song in set['sets']['set'][0]['song']: setlist.append(song['name']) Show(artiste, date, venue, location, setlist)
def make_show_objects(data): for i in range(0, len(data)): Show(artist=find_or_create_artist(data[i]['artist']['name']), date=data[i]['eventDate'], venue=data[i]['venue']['name'], location=(data[i]['venue']['city']['name'] + ', ' + data[i]['venue']['city']['state']), setlist=[ item['name'] for item in data[i]['sets']['set'][0]['song'] ]) return
def modify_shows_record(show_index, show_id): print('Your record to modify is:') print(g.show_list[show_index]) while True: clear() showname = input('Enter the name of the Show: ') showlocation = input('Enter the location of the Show (city/town name): ') showdate = input('Enter the Show Date (YYYY-MM-DD): ') message('You entered {} {} {} '.format(showname, showlocation, showdate)) check = input('Is this correct? "y" or "n": ') if check.lower() == 'y': break update_ind = g.MODIFY show = Show(showname, showlocation, showdate, update_ind) # generate a new replacement object show.set_id(show_id) g.show_list.insert(show_index, show) # insert the object back into the list where it came from for item in g.show_list: print(item)
def make_show_objects(data): for show in data: artist = find_or_create_artist(show['artist']['name']) date = show['eventDate'] venue = show['venue']['name'] location = '{}, {}'.format(show['venue']['city']['name'], show['venue']['city']['state']) setlist = [song['name'] for song in show['sets']['set'][0]['song']] Show(artist=artist, date=date, venue=venue, location=location, setlist=setlist)
def main(): actor1 = Actor("Actor", "1") actor2 = Actor("Actor", "2") actor3 = Actor("Actor", "3") show1 = Show("Monday Show", [actor1, actor2]) show2 = Show("Tuesday Show", [actor1, actor2, actor3]) show3 = Show("Wednesday Show", [actor2, actor3]) channel1 = Channel("DEF", 42, [show1], "Show 1 plays on Mondays") channel2 = Channel( "XYZ", 31, [show2, show3], "Show 2 plays on Tuesdays and Show 3 plays on Wednesdays") channels = set([channel1, channel2]) shows = shows_starring(actor1, channels) for show in shows: print(show) print(channel1.channel_contains(show1)) print(channel1) print(channel2) print(shows_on_days("Monday", channel1.shows))
def showTesselation( gridHeight, gridWidth ): cellPixels = 20 width = cellPixels * gridWidth height = cellPixels * gridHeight ( tile, ySize, xSize ) = tesselation( gridHeight, gridWidth ) surface = cairo.ImageSurface( cairo.FORMAT_ARGB32, width=width, height=height ) context = cairo.Context( surface ) context.set_source_rgba( 1.0, 1.0, 1.0 ) context.rectangle( 0, 0, width, height ) context.fill() colors = [ [ (0.0, 0.0, 1.0), (0.0, 0.5, 0.5), (0.0, 1.0, 0.0) ], [ (0.8, 1.0, 0.8), (0.2, 0.2, 0.2), (0.0, 0.8, 1.0) ], [ (0.5, 0.5, 0.5), (0.0, 0.7, 0.3), (0.0, 0.3, 0.7) ] ] for yi in xrange( 0, gridHeight, ySize ): yc = ( yi / ySize ) % 3 for xi in xrange( 0, gridWidth, xSize ): xc = ( xi / xSize ) % 3 context.set_source_rgba( *(colors[yc][xc]) ) # Special example tile if yi == ySize and xi == xSize: context.set_source_rgba( 1.0, 0.0, 0.0 ) for ( dy, dx ) in tile: y = ( ( yi + dy ) % gridHeight ) * cellPixels x = ( ( xi + dx ) % gridWidth ) * cellPixels yw = cellPixels - 1 xw = cellPixels - 1 # If neighbors exist, extend to meet them if ( dy + 1, dx ) in tile: yw += 1 if ( dy, dx+1 ) in tile: xw += 1 context.rectangle( x, y, xw, yw ) context.fill() Show( surface ).run()
def showSlide(self, show: Show): # Check if Subs or Dubs are available if show.getSub() and show.getDub(): subDub = " (Sub/Dub)" elif show.getSub(): subDub = " (Subbed)" elif show.getDub(): subDub = " (Dubbed)" else: subDub = "" # Fill Slide slide = self.prs.slides.add_slide(self.prs.slide_layouts[2]) slide.placeholders[0].text = show.getTitleENG() slide.placeholders[10].text = show.getTitleJPN() slide.placeholders[11].text = show.getDescription() slide.placeholders[12].insert_picture(show.getGifPath()) slide.placeholders[13].text = f"Episode: {show.getEpisode()}{subDub}\vPremiered: {show.getSeason()}\vSource: {show.getSource()}\vStudio: {show.getStudio()}\vDirector: {show.getDirector()}\vGenres: {show.getGenres()}"
def findAll(self, name, type=None): query = "/search?query=%s" % name.replace(" ", "%20") element = self.server.query(query) items = [] for e in element: if type and e.attrib['type'] != type: continue if e.attrib['type'] == 'show': items.append(Show(e, self.server)) elif e.attrib['type'] == 'movie': items.append(Movie(e, self.server)) elif e.attrib['type'] == 'episode': items.append(Episode(e, self.server)) return items
def input_show_info(): '''get user information about a particular show''' message('') while True: clear() showname = input('Enter the name of the Show: ') showlocation = input('Enter the location of the Show (city/town name): ') showdate = input('Enter the Show Date (YYYY-MM-DD): ') message('You entered {} {} {} '.format(showname, showlocation, showdate)) check = input('Is this correct? "y" or "n": ') if check.lower() == 'y': break update_ind = g.ADD show = Show(showname, showlocation, showdate, update_ind) g.show_list.append(show) for show in g.show_list: message(show)
def showPolyominoes(n): pList = list(allPolyominoes(n)) numPoly = len(pList) cellPixels = 4 maxWidth = 1024 polyPerRow = maxWidth / ((n + 1) * cellPixels) width = polyPerRow * (n + 1) * cellPixels - cellPixels polyRows = (numPoly + polyPerRow - 1) / polyPerRow height = polyRows * (n + 1) * cellPixels - cellPixels currX = 0 currY = 0 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width=width, height=height) context = cairo.Context(surface) context.set_source_rgba(1.0, 1.0, 1.0) context.rectangle(0, 0, width, height) context.fill() context.set_line_width(2) for p in pList: context.set_source_rgba(0.1, 0.2, 1.0, 1) # Polyominoes are aligned their bottom row at 0 # but may extend either +X or -X minX = min(x for (y, x) in p) for (py, px) in p: context.rectangle((currX * (n + 1) + px - minX) * cellPixels, (currY * (n + 1) + py) * cellPixels, cellPixels - 1, cellPixels - 1) context.fill() currX += 1 if currX == polyPerRow: currX = 0 currY += 1 Show(surface).run() surface.write_to_png("fixed-polyominoes-" + str(n) + ".png")
def ab(): opts,args=getopt.getopt(sys.argv[1:],"A:C:c:d:n:eghHip:qsSv:Vwx:X:y:z:") logger.debug(u'ab被调用') for key in opts: logger.debug(key) if ('-h','') in opts: logger.debug(u'显示帮助信息') from data.help import helpDict for key in helpDict: print '%s %s'%(key,helpDict[key]) if ('-V','') in opts: logger.debug(u'请求版本号') print u'VERSION: %.1f'%VERSION optsDict=dict(opts) logger.debug(optsDict) opts=dict(opts) url=args[0] userCount=opts.get('-c',1) visitCount=opts.get('-n',1) userAgent=opts.get('-H',"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-Us) AppleWeb Kit/534.2 (KHTML, like Gecko) Chrome/6.0.447.0 Safari/534.2") outhString=opts.get('-A',None) cookie=opts.get('-C',None) postData=None proxy=None if opts.has_key('-p'): method='POST' postData=opts.get('-p',None) elif opts.has_key('-i'): method='HEAD' else: method='GET' if opts.has_key('-s'): protocal='https' else: protocal='http' if opts.has_key('-X'): proxy=opts.get('-X',None) else: pass parDict={} parDict['url']=url parDict['userCount']=int(userCount) parDict['visitCount']=int(visitCount) parDict['userAgent']=userAgent parDict['outhString']=outhString parDict['cookie']=cookie parDict['method']=method parDict['postData']=postData parDict['protocal']=protocal parDict['proxy']=proxy pressurer=Pressurer(**parDict) resault=pressurer.getCondition() #上面的resault为获得的结果,下面处理展示部分 show=Show(resault) show.outToStdout() def createNameFor(suffix): import datetime return ('%s_user_%s_visit_host_%s_%s.%s'%(userCount,visitCount,url,datetime.datetime.now(),suffix)).replace(' ','_') pass if opts.has_key('-w'): fileName=createNameFor('html') print u'Create file %s'%fileName show.outToHTML(fileName) if opts.has_key('-g'): fileName=createNameFor('TSV') print u'Create file %s'%fileName show.outToTSV(fileName) if opts.has_key('-e'): fileName=createNameFor('csv') print u'Create file %s'%fileName show.outToCSV(fileName)
#!/Python34/python import cgi from connectors import mongodbConnector from show import Show print("Content-type: text/html; charset=utf8") print() form = cgi.FieldStorage() show = Show() show.name = form.getvalue("new_series") show.description = form.getvalue("description") showId = mongodbConnector.addNewShow(show) print("New Series: " + show.name + " with ID '" + str(showId)) print() print("<p>") print("<a href='index.html'>Main Page</a><br>") print("<a href='showguide_insert.py'>Insert Formular</a><br>") print("<a href='showguide_addseries.py'>Add Series Formular</a><br>") print("</p>")