def __init__(self, parent=None): super(CsvParserDialog, self).__init__('CSV Choose the columns', parent_win=parent) self._filename = None # Definition of the forms fields self._filename = ControlFile('CSV File') self._separator = ControlText('Separator', default=';') self._startingrow = ControlNumber('Starting row', default=0) self._frameCol = ControlNumber('Frame column', default=0, minumum=0, maximum=100) self._xCol = ControlNumber('X column', default=1, minumum=0, maximum=100) self._yCol = ControlNumber('Y column', default=2, minumum=0, maximum=100) self._zCol = ControlNumber('Z column', default=3, minumum=0, maximum=100) self._filePreview = ControlList('Preview') self._loadButton = ControlButton('Load') self._formset = [('_filename', '_startingrow'), ('_separator', '_frameCol', '_xCol', '_yCol', '_zCol', '_loadButton'), '_filePreview'] self._separator.changed_event = self.__refreshPreview self._filename.changed_event = self.__refreshPreview self._startingrow.changed_event = self.__refreshPreview
def __init__(self): super(OBSHostPortInput, self).__init__("OBS Websocket") self._host = ControlText("Host IP") self._port = ControlText("Host Port") self._host.value = "localhost" self._port.value = "4444" self._label = ControlLabel( "When I stop recording I want the program to") self._sub = ControlButton("Submit") self._stop = ControlButton("Stop Updates") self.formset = ["_host", "_port", "_label", ("_sub", "_stop")] self._sub.value = self.__sub_action self._stop.value = self.__stop_action
def __init__(self): super(YouTubeSelector, self).__init__("YouTubeSelector") self._youtubes = ControlCombo("Accounts") self._ok = ControlButton("Load") self._new = ControlButton("New Account") self.formset = ["_youtubes", ("_ok", "_new")] accounts = os.listdir(consts.smash_folder) for account in accounts: self._youtubes += (account.split(".")[0], account) self._ok.value = self._ok_action self._new.value = self._new_action
def __init__(self): super(SAHostPortInput, self).__init__("SA Websocket") self._host = ControlText("Host IP") self._port = ControlText("Host Port") self._host.value = "localhost" self._port.value = "58341" self._button = ControlButton("Submit") self.formset = ["_host", "_port", "_button"] self._button.value = self.__button_action
def __init__(self, url=""): super(SMurlInput, self).__init__("Streameta") self._url = ControlText("URL") self._url.value = url.value self._url.form.lineEdit.setPlaceholderText( "http://ns.streameta.com/api/?token=<token>") self._button = ControlButton('Submit') self._button.value = self.__button_action
def __init__(self): super(SimpleExample1, self).__init__('Simple example 1') #Definition of the forms fields self._firstname = ControlText('First name', 'Default value') self._middlename = ControlText('Middle name') self._lastname = ControlText('Lastname name') self._fullname = ControlText('Full name') self._button = ControlButton('Press this button')
def __init__(self, f=""): super(SCFileInput, self).__init__("Stream Control") self._file = ControlFile("File") self.formset = ["_file", "_button"] self._button = ControlButton('Submit') self._file.value = f.value self._file.form.lineEdit.setPlaceholderText( "Find your streamcontrol.json") self._button.value = self.__button_action
def __init__(self, pos, options): super(OptionsViewer, self).__init__(f"Options #{pos}") self.options = options self._oview = ControlList() self._oview.readonly = True self._oview.horizontal_headers = ["Key", "Value"] self.formset = ["_oview"] if pos or consts.stop_thread: self._ignorebutton = ControlButton("Toggle Ignore") self._ignorebutton.value = self.__ignore_job self.formset = ["_oview", "=", "_ignorebutton"] self.__update_o_view()
def __init__(self, pos, options): super(OptionsViewer, self).__init__(f"Options #{pos}") self.pos = pos self.options = options self._oview = ControlList() self._oview.horizontal_headers = ["Key", "Value"] self.formset = ["_oview"] if pos or consts.stop_thread: self._deletebutton = ControlButton("Remove from Queue") self._deletebutton.value = self.__delete_job self.formset = ["_oview", "=", "_deletebutton"] self.__update_o_view() self._oview.data_changed_event = self.__update_data
def __init__(self, mappings={}): super(SCSetup, self).__init__("Stream Control") self._mappings = mappings self._file = ControlFile("File") self._label = ControlLabel( "Uploader Inputs to streamcontrol.json mappings\n") self._p1 = ControlText("P1 Name") self._p2 = ControlText("P2 Name") self._p1_sponsor = ControlText("P1 Sponsor") self._p2_sponsor = ControlText("P2 Sponsor") self._p1_char = ControlText("P1 Character") self._p2_char = ControlText("P2 Character") self._mtype = ControlText("Match Type") self._mprefix = ControlText("Match Prefix") self._button = ControlButton("Submit") self.formset = [ "_file", "_label", "_p1", "_p2", "_p1_sponsor", "_p2_sponsor", "_p1_char", "_p2_char", "_mtype", "_mprefix", (" ", "_button", " "), ] self._p1.value = self._mappings.get("p1_name", "") self._p2.value = self._mappings.get("p2_name", "") self._p1_sponsor.value = self._mappings.get("p1_sponsor", "") self._p2_sponsor.value = self._mappings.get("p2_sponsor", "") self._p1_char.value = self._mappings.get("p1_char", "") self._p2_char.value = self._mappings.get("p2_char", "") self._mtype.value = self._mappings.get("mtype", "") self._mprefix.value = self._mappings.get("mprefix", "") self._file.value = self._mappings.get("file", "") self._file.form.lineEdit.setPlaceholderText( "Find your streamcontrol.json") self._button.value = self.__button_action
def __init__(self, columns, parent=None): super(GenericCsvParserDialog, self).__init__('CSV Choose the columns', parent_win=parent) self._filename = None self._columns = columns self._columns_indexes = [] self._rownum = 0 # Definition of the forms fields self._filename = ControlFile('CSV File') self._separator = ControlCombo('Separator', default='auto') self._startingrow = ControlNumber('Starting row', default=0) for index, column in enumerate(columns): setattr( self, '_col_{0}'.format(index), ControlNumber(column, default=index, minimum=-1, maximum=1000)) self._filePreview = ControlList('Preview') self._loadButton = ControlButton('Load') form_row = ['_separator'] + [ '_col_{0}'.format(index) for index, column in enumerate(columns) ] + ['_loadButton'] self._formset = [('_filename', '_startingrow'), tuple(form_row), '_filePreview'] self._separator.changed_event = self.__refreshPreview self._filename.changed_event = self.__refreshPreview self._startingrow.changed_event = self.__refreshPreview self._loadButton.value = self.load self._load_event = None self._separator.add_item('auto', 'auto') self._separator.add_item(';', ';') self._separator.add_item(',', ',') self._separator.add_item('TAB', '\t') self._separator.add_item('Excel', csv.excel) self._separator.add_item('Excel TAB', csv.excel_tab)
def __init__(self): try: # check if the user can update the app latest_version = requests.get( 'https://pypi.org/pypi/MeleeUploader/json').json( )['info']['version'] if sv(latest_version) > sv( consts.__version__): # prevents messages when developing if "linux" in sys.platform: self.info( f"Current Version: {consts.__version__}\nVersion {latest_version} is available.\nUse sudo pip3 install -U meleeuploader=={latest_version} in terminal to update to the newest verison", title="MeleeUploader") else: resp = self.question( f"Current Version: {consts.__version__}\nVersion {latest_version} is available. Would you like to update?", title="MeleeUploader") if resp == "yes": ret = subprocess.call( ('pip3', 'install', '-U', f'meleeuploader=={latest_version}')) if ret: self.info( f'The app failed to update\nType "pip3 install -U meleeuploader=={latest_version}" into CMD/Terminal to update', title="MeleeUploader") else: self.info( "You can now restart the app to use the new version", title="MeleeUploader") except Exception as e: print(e) if consts.melee: super(MeleeUploader, self).__init__("Melee YouTube Uploader") else: super(MeleeUploader, self).__init__("Smash YouTube Uploader") # Redirct print output sys.stdout = workers.WriteWorker(textWritten=self.write_print) # Redirect error output to window, console, and file sys.stderr = workers.WriteWorker(textWritten=self.write_err) # Websocket self._sa = None self._obs = None # History self.__history = [] # Queue self._queue = Queue() self._queueref = [] # Event Values self._privacy = ControlCombo("Video Privacy") self._titleformat = ControlCombo("Title Format") self._ename = ControlText("Event Name") self._ename_min = ControlText() self._pID = ControlText("Playlist ID") self._bracket = ControlText("Bracket Link") self._tags = ControlText("Tags") self._description = ControlTextArea("Description") # Match Values self._file = ControlFile("File") self._p1 = ControlText() self._p2 = ControlText() self._p1sponsor = ControlText("P1") self._p2sponsor = ControlText("P2") self._p1char = ControlCheckBoxList("P1 Characters") self._p2char = ControlCheckBoxList("P2 Characters") self._mtype = ControlCombo() self._mprefix = ControlText() self._msuffix = ControlText() # Output Box self._output = ControlTextArea() self._output.readonly = True self._qview = ControlList("Queue", select_entire_row=True) self._qview.cell_double_clicked_event = self.__show_o_view self._qview.readonly = True self._qview.horizontal_headers = ["Player 1", "Player 2", "Round"] # Button self._button = ControlButton('Submit') self._button.value = self.__button_action # Title Formats for f in consts.titleformat: self._titleformat += f # Form Layout self.formset = [{ "-Match": [ "_file", (' ', "_mprefix", "_mtype", "_msuffix", ' '), (' ', "_p1sponsor", "_p1", ' '), (' ', "_p1char", ' '), (' ', "_p2sponsor", "_p2", ' '), (' ', "_p2char", ' ') ], "-Status-": ["_output", "=", "_qview"], "Event-": [ "_privacy", "_titleformat", ("_ename", "_ename_min"), "_pID", "_bracket", "_tags", "_description" ] }, (' ', '_button', ' ')] # Main Menu Layout self.mainmenu = [{ 'Settings': [{ 'YouTube Log Out': self.__reset_cred }, { 'Toggle OBS Hook': self.__show_obs_form }, { 'Toggle SA Hook': self.__show_sa_form }, { 'Toggle SC Hook': self.__show_sc_form }, { 'Toggle Streameta Hook': self.__show_sm_form }, { 'About': self.__about_info }], 'Save/Clear': [{ 'Save Form': self.__save_form }, { 'Clear Match Values': self.__reset_match }, { 'Clear Event Values': self.__reset_event }, { 'Clear All': self.__reset_forms }], 'Queue': [{ 'Toggle Uploads': utils.toggle_worker }, { 'Save Queue': self.__save_queue }, { 'Load Queue': self.__load_queue }], 'History': [{ 'Show History': self.__show_h_view }], 'Characters': [{ 'Melee': self.__melee_chars }, { 'Ultimate': self.__ultimate_chars }, { 'Custom': self.__custom_chars }] }] # Add ControlCombo values for t in consts.match_types: self._mtype += t for t in ("public", "unlisted", "private"): self._privacy += t # Set placeholder text self._ename_min.form.lineEdit.setPlaceholderText( "Shortened Event Name") self._p1sponsor.form.lineEdit.setPlaceholderText("Sponsor Tag") self._p2sponsor.form.lineEdit.setPlaceholderText("Sponsor Tag") self._p1.form.lineEdit.setPlaceholderText("P1 Tag") self._p2.form.lineEdit.setPlaceholderText("P2 Tag") self._mprefix.form.lineEdit.setPlaceholderText("Round Prefix") self._msuffix.form.lineEdit.setPlaceholderText("Round Suffix") self._bracket.form.lineEdit.setPlaceholderText("Include https://") self._tags.form.lineEdit.setPlaceholderText("Separate with commas") self._pID.form.lineEdit.setPlaceholderText("Accepts full YT link") # For pulling characters self.__p1chars = [] self.__p2chars = [] # Set character list if consts.melee: self.__melee_chars() else: self.__ultimate_chars() # Stream Control self._sc = None self._scf = ControlText() self._scf.value = "" # Streameta self._sm = None self._smf = ControlText() self._smf.value = "" # Define the existing form fields self._form_fields = (self._ename, self._pID, self._mtype, self._p1, self._p2, self._p1char, self._p2char, self._bracket, self._file, self._tags, self._msuffix, self._mprefix, self._p1sponsor, self._p2sponsor, self._privacy, self._description, self._ename_min, self._titleformat, self._scf, self._smf) # Get latest values from form_values.txt self.__load_form()
def __init__(self): try: # check if the user can update the app latest_version = (requests.get( "https://pypi.org/pypi/MeleeUploader/json").json().get( "info", {}).get("version")) if sv(latest_version) > sv( consts.__version__): # prevents messages when developing if "linux" in sys.platform: self.info( f"Current Version: {consts.__version__}\nVersion {latest_version} is available.\nUse sudo pip3 install -U meleeuploader=={latest_version} in terminal to update to the newest verison", title="MeleeUploader", ) else: resp = self.question( f"Current Version: {consts.__version__}\nVersion {latest_version} is available. Would you like to update?", title="MeleeUploader", ) if resp == "yes": ret = subprocess.call(( "pip3", "install", "-U", f"meleeuploader=={latest_version}", )) if ret: self.info( f'The app failed to update\nType "pip3 install -U meleeuploader=={latest_version}" into CMD/Terminal to update', title="MeleeUploader", ) else: self.info( "You can now restart the app to use the new version", title="MeleeUploader", ) except Exception as e: print(e) super(MeleeUploader, self).__init__(f"Melee YouTube Uploader - {consts.__version__}") # Redirct print output sys.stdout = workers.WriteWorker(textWritten=self.write_print) # Websocket self._sa = None self._obs = None # History self.__history = [] # Queue self._queue = Queue() self._queueref = ( []) # out of order access to all the items in _queue with mutation consts.start_queue = True if "-q" in sys.argv else False # Event Values self._privacy = ControlCombo("Video Privacy") self._title_format = ControlCombo("Title Format") self._ename = ControlText("Event Name") self._ename_min = ControlText() self._pID = ControlText("Playlist ID") self._bracket = ControlText("Bracket Link") self._tags = ControlText("Tags") self._description = ControlTextArea("Description") self._timestamp_start = None self._timestamps = [] # Match Values self._file = ControlFile("File") self._p1 = ControlText() self._p2 = ControlText() self._p1_sponsor = ControlText("P1") self._p2_sponsor = ControlText("P2") self._p1char = ControlCheckBoxList("P1 Characters") self._p2char = ControlCheckBoxList("P2 Characters") self._mtype = ControlCombo() self._mprefix = ControlText() self._msuffix = ControlText() # Output Box self._output = ControlTextArea() self._output.readonly = True self._qview = ControlList("Queue", select_entire_row=True) self._qview.cell_double_clicked_event = self.__show_oview self._qview.readonly = True self._qview.horizontal_headers = ["Player 1", "Player 2", "Round"] # Button self._submit_button = ControlButton("Submit") self._submit_button.value = self.__on_submit self._timestamp_button = ControlButton("Record Timestamp") self._timestamp_button.value = self.__on_timestamp # Title Formats for f in consts.title_format: self._title_format += f # Form Layout self.formset = [ { "-Match": [ "_file", (" ", "_mprefix", "_mtype", "_msuffix", " "), (" ", "_p1_sponsor", "_p1", " "), (" ", "_p1char", " "), (" ", "_p2_sponsor", "_p2", " "), (" ", "_p2char", " "), (" ", "_timestamp_button", " "), ], "-Status-": ["_output", "=", "_qview"], "Event-": [ "_privacy", "_title_format", ("_ename", "_ename_min"), "_pID", "_bracket", "_tags", "_description", ], }, (" ", "_submit_button", " "), ] # Main Menu Layout self.mainmenu = [{ "Settings": [ { "YouTube Log Out": self.__reset_yt_cred }, { "Toggle OBS Hook": self.__show_obs_form }, { "Toggle SA Hook": self.__show_sa_form }, { "Toggle SC Hook": self.__show_sc_form }, { "Toggle Streameta Hook": self.__show_sm_form }, { "About": self.__about_info }, ], "Save/Clear": [ { "Save Form": self.__save_form }, { "Clear Match Values": self.__reset_match }, { "Clear Event Values": self.__reset_event }, { "Clear All": self.__reset_forms }, ], "Queue": [ { "Toggle Uploads": utils.toggle_worker }, { "Save Queue": self.__save_queue }, { "Load Queue": self.__load_queue }, { "Toggle Save on Submit": self.__save_on_submit }, ], "History": [{ "Show History": self.__show_hview }], "Characters": [ { "Melee": self.__melee_chars }, { "Ultimate": self.__ultimate_chars }, { "64": self.__64_chars }, { "Rivals": self.__rivals_chars }, { "Splatoon": self.__splatoon_chars }, { "Strive": self.__strive_chars }, { "NASB": self.__nasb_chars }, { "Custom": self.__custom_chars }, ], }] # Add ControlCombo values for t in consts.match_types: self._mtype += t for t in ("unlisted", "public", "private"): self._privacy += t # Set placeholder text self._ename_min.form.lineEdit.setPlaceholderText( "Shortened Event Name") self._p1_sponsor.form.lineEdit.setPlaceholderText("Sponsor Tag") self._p2_sponsor.form.lineEdit.setPlaceholderText("Sponsor Tag") self._p1.form.lineEdit.setPlaceholderText("P1 Name") self._p2.form.lineEdit.setPlaceholderText("P2 Name") self._mprefix.form.lineEdit.setPlaceholderText("Round Prefix") self._msuffix.form.lineEdit.setPlaceholderText("Round Suffix") self._bracket.form.lineEdit.setPlaceholderText("Include https://") self._tags.form.lineEdit.setPlaceholderText("Separate with commas") self._pID.form.lineEdit.setPlaceholderText( "Accepts full YT link or a new playlist title") # For pulling characters self.__p1chars = [] self.__p2chars = [] # Set character list self.game_chars = { "64": self.__64_chars, "melee": self.__melee_chars, "ult": self.__ultimate_chars, "rivals": self.__rivals_chars, "splatoon": self.__splatoon_chars, "strive": self.__strive_chars, "custom": self.__custom_chars, } self.game_chars[consts.game]() # Stream Control self._sc = None self.__sc_mapping = { # defaults are based on Recursion's setup "file": "", "p1_name": "p1_name", "p2_name": "p2_name", "p1_char": "p1_char", "p2_char": "p2_char", "p1_sponsor": "p1_sponsor", "p2_sponsor": "p2_sponsor", "mtype": "event_round", "mprefix": "event_bracket", } # Streameta self._sm = None self._smf = ControlText() self._smf.value = "" # Define the mapping of the form values json to form fields self._form_fields = { "ename": self._ename, "pID": self._pID, "mtype": self._mtype, "p1": self._p1, "p2": self._p2, "p1char": self._p1char, "p2char": self._p2char, "bracket": self._bracket, "file": self._file, "tags": self._tags, "msuffix": self._msuffix, "mprefix": self._mprefix, "p1sponsor": self._p1_sponsor, "p2sponsor": self._p2_sponsor, "privacy": self._privacy, "description": self._description, "ename_min": self._ename_min, "title_format": self._title_format, "streameta_url": self._smf, } # Get latest values from form_values.txt if consts.start_queue: self.__load_queue() else: self.__load_form()
class CsvParserDialog(BaseWidget): def __init__(self, parent=None): super(CsvParserDialog, self).__init__('CSV Choose the columns', parent_win=parent) self._filename = None # Definition of the forms fields self._filename = ControlFile('CSV File') self._separator = ControlText('Separator', default=';') self._startingrow = ControlNumber('Starting row', default=0) self._frameCol = ControlNumber('Frame column', default=0, minumum=0, maximum=100) self._xCol = ControlNumber('X column', default=1, minumum=0, maximum=100) self._yCol = ControlNumber('Y column', default=2, minumum=0, maximum=100) self._zCol = ControlNumber('Z column', default=3, minumum=0, maximum=100) self._filePreview = ControlList('Preview') self._loadButton = ControlButton('Load') self._formset = [('_filename', '_startingrow'), ('_separator', '_frameCol', '_xCol', '_yCol', '_zCol', '_loadButton'), '_filePreview'] self._separator.changed_event = self.__refreshPreview self._filename.changed_event = self.__refreshPreview self._startingrow.changed_event = self.__refreshPreview #self._filename.value = '/home/ricardo/Downloads/2012.12.01_13.48_3D_POSITIONS_version_03.06.2015.csv' @property def filename(self): return self._filename.value @filename.setter def filename(self, value): self._filename.value = value self.__refreshPreview() @property def load_file_event(self): return self._loadButton.value @load_file_event.setter def load_file_event(self, value): self._loadButton.value = value @property def separator(self): return self._separator.value @property def starting_row(self): return self._startingrow.value @starting_row.setter def starting_row(self, value): self._startingrow.value = value @property def frameColumn(self): return self._frameCol.value @frameColumn.setter def frameColumn(self, value): self._frameCol.value = value @property def xColumn(self): return self._xCol.value @xColumn.setter def xColumn(self, value): self._xCol.value = value @property def yColumn(self): return self._yCol.value @yColumn.setter def yColumn(self, value): self._yCol.value = value @property def zColumn(self): return self._zCol.value @zColumn.setter def zColumn(self, value): self._zCol.value = value @property def loadButton(self): return self._loadButton @property def xField(self): return self._xCol @property def yField(self): return self._yCol @property def zField(self): return self._zCol def __iter__(self): if self._filename.value != None and self._filename.value != '': csvfile = open(self._filename.value, 'U') self._spamreader = csv.reader(csvfile, delimiter=self._separator.value) for i in range(int(self._startingrow.value)): next(self._spamreader, None) # skip the headers self._cols = [self.frameColumn] if self.xField.visible: self._cols.append(self.xColumn) if self.yField.visible: self._cols.append(self.yColumn) if self.zField.visible: self._cols.append(self.zColumn) else: self._spamreader = None return self # For compatibility with python 3 def __next__(self): return self.next() def next(self): if self._spamreader != None: row = next(self._spamreader) return [row[int(col)] for col in self._cols] else: raise StopIteration() def __refreshPreview(self): if self._filename.value != None and self._filename.value != '': with open(self._filename.value, 'U') as csvfile: spamreader = csv.reader(csvfile, delimiter=self._separator.value) for i in range(int(self._startingrow.value)): next(spamreader, None) # skip the headers self._filePreview.value = [] self._filePreview.horizontalHeaders = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", ] for i, row in enumerate(spamreader): self._filePreview += row if i >= 10: break def load(self): self.__refreshPreview() self._loadButton.value()