def draw(shared, conn, beatmap, replay_info, resultinfo, videotime, settings, showranking): asdfasdf = time.time() logger.log(1, "CALL {}, {}".format(videotime, showranking)) logger.debug("process start") ur = getunstablerate(resultinfo) frames = PreparedFrames(settings, beatmap.diff, replay_info.mod_combination, ur=ur, bg=beatmap.bg, loadranking=showranking) drawer = Drawer(shared, beatmap, frames, replay_info, resultinfo, videotime, settings) logger.log(1, "PROCESS {}, {}".format(videotime, drawer)) logger.debug("setup done") logger.debug("Starting draw") timer = 0 timer2 = 0 timer3 = 0 while drawer.frame_info.osr_index < videotime[1]: status = drawer.render_draw() asdf = time.time() if status: conn.send(1) timer3 += time.time() - asdf asdf = time.time() i = conn.recv() timer2 += time.time() - asdf if showranking: for x in range(int(5 * settings.fps)): drawer.draw_rankingpanel() conn.send(1) i = conn.recv() conn.send(10) logger.debug("End draw: %f", time.time() - asdfasdf) logger.debug("\nprocess done {}, {}".format(videotime, drawer)) logger.debug("Drawing time: {}".format(timer)) logger.debug("Total time: {}".format(time.time() - asdfasdf)) logger.debug("Waiting time: {}".format(timer2)) logger.debug("Changing value time: {}".format(timer3))
def checkmain(beatmap, replay_info, settings, tests=False): osr_index = 0 replay_event = replay_info.play_data diffmod(replay_info, beatmap.diff) hitobjectchecker = HitObjectChecker(beatmap, settings, replay_info, tests) break_index = 0 breakperiod = beatmap.breakperiods[break_index] in_break = int(replay_event[osr_index][Replays.TIMES]) in range( breakperiod["Start"], breakperiod["End"]) logger.debug("Start check") while osr_index < len(replay_event) - 3: k1, k2, m1, m2 = keys(replay_event[osr_index][Replays.KEYS_PRESSED]) if not in_break: f_k1, f_k2, f_m1, f_m2 = keys( replay_event[osr_index + 1][Replays.KEYS_PRESSED]) else: f_k1, f_k2, f_m1, f_m2 = False, False, False, False new_k1, new_k2 = f_k1 and not k1, f_k2 and not k2 new_m1, new_m2 = f_m1 and not m1, f_m2 and not m2 new_click = [new_k1, new_k2, new_m1, new_m2] hitobjectchecker.checkcursor(replay_event, new_click, osr_index + 1, in_break, breakperiod) osr_index += 1 breakperiod = beatmap.breakperiods[break_index] next_break = replay_event[osr_index][ Replays.TIMES] > breakperiod["End"] if next_break: break_index = min(break_index + 1, len(beatmap.breakperiods) - 1) breakperiod = beatmap.breakperiods[break_index] in_break = int(replay_event[osr_index][Replays.TIMES]) in range( breakperiod["Start"], breakperiod["End"]) logger.debug("check done") logger.log(1, "RETURN %r", hitobjectchecker.info[-1]) return hitobjectchecker.info
def read(self): config = ConfigParser(strict=False, comment_prefixes=["//", "\\"], inline_comment_prefixes="//", dict_type=MultiOrderedDict) config.optionxform = str try: with open(self.skin_path, encoding='utf-8', errors='ignore') as file: lines = file.read() except FileNotFoundError: with open(self.default_path, encoding='utf-8', errors='ignore') as file: lines = file.read() lines = self.filter(lines) config.read_string(lines) self.general = getsection(config, "General") self.colours = getsection(config, "Colours") self.fonts = getsection(config, "Fonts") logger.log(1, self.general) logger.log(1, self.colours) logger.log(1, self.fonts)
def __init__(self, data=None, gameplaysettings=None, ppsettings=None, strainsettings=None, filedata=None, filesettings=None, filepp=None, filestrain=None, logtofile=False, enablelog=True, logpath=""): self.settings = Settings() sys.excepthook = excepthook self.settings.path = os.path.dirname( os.path.abspath(inspect.getsourcefile(Dummy))) self.settings.path = os.path.relpath(self.settings.path) if self.settings.path[-1] != "/" and self.settings.path[-1] != "\\": self.settings.path += "/" if logpath == "": logpath = os.path.join(self.settings.path, "logosr2mp4.log") logging.getLogger(PIL.__name__).setLevel(logging.WARNING) fmt = logging.Formatter( "%(asctime)s:%(levelname)s:%(name)s:%(funcName)s:%(message)s") logger.setLevel(TRACE) if logtofile: handler = logging.FileHandler(logpath) elif enablelog: handler = logging.StreamHandler(sys.stdout) else: handler = logging.NullHandler() logger.handlers.clear() handler.setFormatter(fmt) logger.addHandler(handler) self.settings.enablelog = enablelog self.settings.temp = os.path.join(self.settings.path, str(uuid.uuid1()) + "temp/") self.__log.info("test") setup_dir(self.settings) atexit.register(self.cleanup) if gameplaysettings is None: gameplaysettings = defaultsettings if ppsettings is None: ppsettings = defaultppconfig if strainsettings is None: strainsettings = defaultstrainconfig if filedata is not None: data = read(filedata) if filesettings is not None: gameplaysettings = read(filesettings) if filepp is not None: ppsettings = read(filepp) if filestrain is not None: strainsettings = read(filestrain) if os.path.isdir(data["Output path"]): data["Output path"] = os.path.join(data["Output path"], "output.avi") self.data = data replaypath = data[".osr path"] starttime = data["Start time"] endtime = data["End time"] self.settings.codec = data["Video codec"] self.settings.audiocodec = data.get("Audio codec", "aac") self.settings.process = data["Process"] apikey = gameplaysettings["api key"] gameplaysettings["api key"] = None # avoid logging api key self.drawers, self.writers, self.pipes, self.sharedarray = None, None, None, None self.audio = None self.auto = auto = replaypath == "auto" gameplaysettings["Custom mods"] = gameplaysettings.get( "Custom mods", "") self.replayedit = False if not auto: try: self.replay_info = parse_replay_file(replaypath) except FileNotFoundError as e: raise ReplayNotFound() from None reverse_replay = False if gameplaysettings["Custom mods"] != "": self.replayedit = True original = self.replay_info.mod_combination self.replay_info.mod_combination = mod_string_to_enums( gameplaysettings["Custom mods"]) if Mod.HardRock in self.replay_info.mod_combination and Mod.HardRock not in original: reverse_replay = True if Mod.HardRock not in self.replay_info.mod_combination and Mod.HardRock in original: reverse_replay = True setupglobals(self.data, gameplaysettings, self.replay_info.mod_combination, self.settings, ppsettings=ppsettings, strainsettings=strainsettings) self.beatmap_file = get_osu(self.settings.beatmap, self.replay_info.beatmap_hash) self.beatmap = read_file(self.beatmap_file, self.settings.playfieldscale, self.settings.skin_ini.colours, mods=self.replay_info.mod_combination, lazy=False) self.replay_event, self.cur_time = setup_replay( replaypath, self.beatmap, reverse=reverse_replay) self.replay_info.play_data = self.replay_event else: gameplaysettings["Custom mods"] = gameplaysettings.get( "Custom mods", "") mod_combination = mod_string_to_enums( gameplaysettings["Custom mods"]) setupglobals(self.data, gameplaysettings, mod_combination, self.settings, ppsettings=ppsettings, strainsettings=strainsettings) self.beatmap_file = self.settings.beatmap self.settings.beatmap = os.path.dirname(self.settings.beatmap) self.beatmap = read_file(self.beatmap_file, self.settings.playfieldscale, self.settings.skin_ini.colours, mods=mod_combination, lazy=False) self.replay_info = get_auto(self.beatmap) self.replay_info.mod_combination = mod_combination add_useless_shits(self.replay_info.play_data, self.beatmap) self.cur_time = self.replay_info.play_data[0][Replays.TIMES] self.replay_event = self.replay_info.play_data self.start_index, self.end_index = find_time(starttime, endtime, self.replay_event, self.settings) self.starttime, self.endtime = starttime, endtime self.resultinfo = None self.previousprogress = 0 logger.log(TRACE, "Settings vars {}".format(vars(self.settings))) gameplaysettings["api key"] = apikey # restore api key