示例#1
0
 def action(self, event):
     """Replay a `count` number of time."""
     toggle_button = event.GetEventObject()
     toggle_button.Parent.panel.SetFocus()
     self.infinite = settings.CONFIG.getboolean('DEFAULT',
                                                'Infinite Playback')
     if toggle_button.Value:
         if not self.count_was_updated:
             self.count = settings.CONFIG.getint('DEFAULT', 'Repeat Count')
             self.count_was_updated = True
         if TMP_PATH is None or not os.path.isfile(TMP_PATH):
             wx.LogError("No capture loaded")
             event = self.ThreadEndEvent(count=self.count,
                                         toggle_value=False)
             wx.PostEvent(toggle_button.Parent, event)
             return
         with open(TMP_PATH, 'r') as f:
             capture = f.readlines()
         if self.count > 0 or self.infinite:
             self.count = self.count - 1 if not self.infinite else self.count
             self.play_thread = PlayThread()
             self.play_thread.daemon = True
             self.play_thread = PlayThread(target=self.play,
                                           args=(
                                               capture,
                                               toggle_button,
                                           ))
             self.play_thread.start()
     else:
         self.play_thread.end()
         self.count_was_updated = False
         settings.save_config()
示例#2
0
    async def set_modrole(self, ctx, *, role_id=None):
        """Set the role for moderators"""

        guild_id = ctx.guild.id

        if not role_id:
            await ctx.send(f"Usage: modrole role_id", delete_after=5)
            return

        if not ctx.guild.get_role(int(role_id)):
            ctx.send(f"Role with that ID could not be found", delete_after=5)
            return

        settings.set_value(guild_id, 'modrole', role_id)

        try:
            settings.save_config()

            await ctx.send(
                f'Moderator role changed to "{ctx.guild.get_role(int(role_id))}", {owouwu.gen()}'
            )
            print(
                f'Moderator role for {ctx.guild.id} ({ctx.guild.name}) changed to "{ctx.guild.get_role(int(role_id))}"'
            )
            await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Command failed to execute', delete_after=5)
示例#3
0
    async def set_role(self, ctx, *, role_id=None):
        """Set no filter role"""

        guild_id = ctx.guild.id

        if not role_id:
            await ctx.send("Usage: filterrole role_id", delete_after=5)
            return

        try:
            role = ctx.guild.get_role(int(role_id))
            # save file
            settings.set_value(guild_id, 'filterrole', role_id)
            try:
                settings.save_config()
            except:
                await ctx.send(f'Command failed to execute', delete_after=5)
        except:
            print(f'Role for ID {role_id} not found')
            await ctx.send(f'Role for ID {role_id} not found', delete_after=5)
            return

        print(
            f'No filter role set to {ctx.guild.get_role(int(role_id))} in guild {ctx.guild.name}-{guild_id}'
        )
        await ctx.send(
            f'No filter role set to "{ctx.guild.get_role(int(role_id))}", {owouwu.gen()}',
            delete_after=5)
        await ctx.message.add_reaction('✅')
示例#4
0
 def login_dialog(self):
     while True:
         config['utm5']['login'], ok1 = QtGui.QInputDialog.getText(None,
                'Вход в личный кабинет', 'Введите логин:')
         config['utm5']['passwd'], ok2 = QtGui.QInputDialog.getText(None,
                'Вход в личный кабинет', 'Введите пароль:')
         if ok1 and ok2: break
     save_config()
示例#5
0
    def on_confirm_button(self, widget):
        server = self.server_entry.get_text()
        if self.save_default_btn.get_active():
            options = load_config()
            options["http_stream_server"] = server
            save_config(options)

        self.emit("server-selected", server)
        self.close()
示例#6
0
    def on_confirm_button(self, widget):
        server = self.server_entry.get_text()
        if self.save_default_btn.get_active():
            options = load_config()
            options["http_stream_server"] = server
            save_config(options)

        self.emit("server-selected", server)
        self.close()
示例#7
0
文件: scenes.py 项目: alucebur/snake
    def save_config(self):
        """Apply and save new settings."""
        settings.set_settings("sound", round(self.sound, 1))
        settings.set_settings("music", round(self.music, 1))
        settings.set_settings("classic", self.classic)
        settings.save_config()

        # Set volumes
        resources.set_volume(settings.get_setting("sound"))
        pygame.mixer.music.set_volume(settings.get_setting("music"))
示例#8
0
 def language(self, event):
     """Manage the language among the one available."""
     menu = event.EventObject
     item = menu.FindItemById(event.Id)
     settings.CONFIG['DEFAULT']['Language'] = item.GetItemLabelText()
     settings.save_config()
     dialog = wx.MessageDialog(None,
                               message="Restart the program to apply modifications",
                               pos=wx.DefaultPosition)
     dialog.ShowModal()
示例#9
0
    async def filter_command(self, ctx, *, input=None):
        """Adjust filtered words"""

        guild_id = ctx.guild.id

        if not input:
            await ctx.send(f'Usage: filter add/remove word', delete_after=5)
            return

        args = input.split()

        if (len(args) < 2):
            await ctx.send(f'Usage: filter add/remove word', delete_after=5)
            return

        filter = json.loads(settings.get_value(guild_id, 'filter'))
        words = input.split()
        del words[0]  # delete the first term, the "operand"

        if (args[0] == 'add'):
            for word in words:
                filter.append(word)
        elif (args[0] == 'remove'):
            for word in words:
                filter.remove(word)
        else:
            await ctx.send(f'Usage: filter add/remove word word word',
                           delete_after=5)
            return

        # save the file, convert the ' to " first, since json dies
        settings.set_value(guild_id, 'filter', f'{filter}'.replace('\'', '"'))

        try:
            settings.save_config()

            if (args[0] == 'add'):
                await ctx.send(
                    f'{len(words)} words added to filter, {owouwu.gen()}',
                    delete_after=5)
            elif (args[0] == 'remove'):
                await ctx.send(
                    f'{len(words)} words removed from filter, {owouwu.gen()}',
                    delete_after=5)

            await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Command failed to execute', delete_after=5)
示例#10
0
def setup_guilds_config(guilds):
    # setup for each guild
    for guild in guilds:
        # :fr:
        if guild.name == None:
            return

        # if config for guild not existing, create
        if not str(guild.id) in cfg.config.sections():
            cfg.config[guild.id] = settings.default_config()

            # write changes
            settings.save_config()

        # make logs for each guild
        make_dir_if_needed(f'logs/guilds/{guild.id}')
示例#11
0
 def action(self, event):
     """
      Replay a count number of time.
     """
     toggle_button = event.GetEventObject()
     count = settings.CONFIG.getint('DEFAULT', 'Repeat Count')
     infinite = settings.CONFIG.getboolean('DEFAULT', 'Infinite Playback')
     if toggle_button.Value:
         if TMP_PATH is None or not os.path.isfile(TMP_PATH):
             wx.LogError("No capture loaded")
             toggle_button.Value = False
             return
         with open(TMP_PATH, 'r') as f:
             capture = f.read()
         if capture == HEADER:
             wx.LogError("Empty capture")
             toggle_button.Value = False
             return
         if count == 1 and not infinite:
             self.play_thread = Thread()
             self.play_thread.daemon = True
             self.play_thread = Thread(target=self.play,
                                       args=(
                                           capture,
                                           toggle_button,
                                       ))
             self.play_thread.start()
         else:
             i = 1
             while i <= count or infinite:
                 self.play_thread = Thread()
                 self.play_thread = Thread(target=self.play,
                                           args=(
                                               capture,
                                               toggle_button,
                                           ))
                 self.play_thread.start()
                 self.play_thread.join()
                 i += 1
     else:
         if getattr(sys, 'frozen', False):
             path = os.path.join(Path(__file).parent.absolute(), 'atbswp')
         else:
             path = os.path.join(
                 Path(__file__).parent.absolute(), 'atbswp.py')
         settings.save_config()
         os.execl(path)
示例#12
0
文件: node.py 项目: ppsirg/arkblock
def main():
    # get port from commandline
    parse_command_line()
    # configuration
    host = options.ip
    port = options.port
    node_name = options.node_name
    app = make_blockchain_app(node_name)
    http_server = tornado.httpserver.HTTPServer(app)
    save_config(node_name, host, port)
    # launch listener server
    http_server.listen(port)
    logging.warning(f"Listening http on {host}:{port}...")
    # launch services
    current = IOLoop.current()
    current.spawn_callback(mining_process, node_name)
    IOLoop.instance().start()
示例#13
0
文件: scenes.py 项目: alucebur/snake
    def add_highscore(self):
        """Adds highscore to data and file."""
        date = str(datetime.date.today())
        new_highscore = {
            "name": self.initials,
            "score": self.score,
            "date": date
        }

        top = settings.get_highscores()
        top.append(new_highscore)
        # Highscore list is sorted by score (desc) and date (asc)
        top.sort(key=lambda x: (-x['score'], x['date']))
        if len(top) > 5:
            top.pop()

        # Save to file
        settings.save_config()
示例#14
0
def __atualiza_imposto_122741():
    import database
    import core
    db = database.InventoryDB()
    line = db.categories_list()
    for data in line:
        try:
            imposto_122741(data=data)
            db.edit_category_impostos(data)
        except exception.ExceptionNCM:
            continue
        except exception.ExceptionInternet:
            continue
    settings.CONFIG.set(settings.CONFIG_SECTION_SAT,
                        settings.CONFIG_FIELD_LAST_UPDATE_IMPOSTO,
                        core.datetime_today()[0])

    settings.save_config()
示例#15
0
    def __init__(self, parent=None, app=None):

        super(QWingsChat, self).__init__(parent)

        self.app = app
        self.error = 0

        self.setWindowTitle('КрыльяITV :: Чат')
        self.setWindowIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__), 'wings_logo.png')))

        self.parser = ChatMsgParser()
        self.template = open(os.path.join(os.path.dirname(__file__), 'chattemplate.html')).read()

        if config['chat']['login'] is None:
            while True:
                login, ok = QtGui.QInputDialog.getText(self, 'Вход в чат', 'Выберите имя:')
                if ok:
                    break
            config['chat']['login'] = login
            save_config()
        else:
            login = config['chat']['login']

        self.chat = QWebView()
        self.chat.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
        self.message = QWingsChatLineEdit(login)

        vb = QtGui.QVBoxLayout()
        vb.setMargin(0)
        vb.setSpacing(0)
        vb.addWidget(self.chat)
        vb.addWidget(self.message)
        self.setLayout(vb)

        self.chat.setHtml(self.template)

        self.http = QHttp('torrent.mnx.net.ru')
        self.connect(self.http, QtCore.SIGNAL("done(bool)"), self.update_chat)

        self.timer = QtCore.QTimer()
        self.timer.singleShot(0, self.send_update_request)
示例#16
0
    async def set_logging(self, ctx, *, option: str):
        """Set guild logging yes/no"""

        guild_id = ctx.guild.id

        if not option or (option != 'yes' and option != 'no'):
            await ctx.send(f'Usage: logging yes/no', delete_after=5)
            return

        settings.set_value(guild_id, 'loggingenabled', option)

        try:
            settings.save_config()

            await ctx.send(f'Logging set to "{option}", {owouwu.gen()}')
            print(
                f'Logging for guild {ctx.guild.name} - {guild_id} set to "{option}", {owouwu.gen()}'
            )
            await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Command failed to execute', delete_after=5)
示例#17
0
    async def set_prefix(self, ctx, *, prefix=None):
        """Set the prefix for all commands"""

        guild_id = ctx.guild.id

        if not prefix:
            await ctx.send(f"Usage: prefix prefix", delete_after=5)
            return

        settings.set_value(guild_id, 'prefix', prefix)

        try:
            settings.save_config()

            await ctx.send(f'Prefix changed to "{prefix}')
            print(
                f'Prefix for {ctx.guild.id} ({ctx.guild.name}) changed to "{prefix}"'
            )
            await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Command failed to execute', delete_after=5)
示例#18
0
    async def set_logchannel(self, ctx, *, channel_id: str):
        """Set guild logs channel"""

        guild_id = ctx.guild.id

        if not channel_id:
            await ctx.send(f'Usage: logchannel channel_id', delete_after=5)
            return

        try:
            if ctx.guild.get_channel(int(channel_id)):
                settings.set_value(guild_id, 'logchannel', channel_id)
                settings.save_config()

                await ctx.send(
                    f'Logging channel set to "{channel_id}", {owouwu.gen()}')
                print(
                    f'Logging channel for guild {ctx.guild.name} - {guild_id} set to "{channel_id}", {owouwu.gen()}'
                )
                await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Usage: logchannel channel_id', delete_after=5)
            return
示例#19
0
    def save_settings(self, this_session_only=False):
        ui_config = self.get_ui_config()

        if not ui_config:
            QMessageBox.critical(self, "Save error",
                                 "Saving new configuration has failed."
                                 "Fix the configuration options manually "
                                 "or reset to default settings and then save")
        else:
            if not this_session_only:
                if not settings.save_config(ui_config):
                    QMessageBox.critical(self, "Save error",
                                         "Saving new configuration has failed. "
                                         "The required file or folder could not be saved or created "
                                         "as '{}'".format(settings.config_file))
                    return

            if this_session_only:
                self.load_settings(from_dict=ui_config)
            else:
                self.load_settings()

            self.toggle_settings()
示例#20
0
 def on_confirm_button(self, widget):
     save_config(self.options)
     self.emit("config-saved")
     self.close()
示例#21
0
 def on_confirm_button(self, widget):
     save_config(self.options)
     self.emit("config-saved")
     self.close()
示例#22
0
 def toggle_chat(self):
     self.chat.setVisible(not self.chat.isVisible())
     config['chat']['show'] = str(self.chat.isVisible())
     save_config()
示例#23
0
文件: scenes.py 项目: alucebur/snake
 def save_config(self):
     """Apply and save new controls."""
     settings.set_keybinding(self.keys)
     settings.save_config()
示例#24
0
文件: gui.py 项目: MStopa/atbswp
 def on_exit_app(self, event):
     """Clean exit saving the settings."""
     settings.save_config()
     self.Destroy()
     self.taskbar.Destroy()
示例#25
0
文件: gui.py 项目: juicetin/atbswp
 def on_exit_app(self, event):
     settings.save_config()
     self.Destroy()
     self.taskbar.Destroy()