Example #1
0
 async def handle_post(self, resource, data):
     if not await l.OptionLoader(self.mailer, self, resource).get(
             util.get('option', data)):
         return httpsvc.ResponseBody.NOT_FOUND
     cmdline = OptionCommandHandler.COMMANDS.get(data)
     if not cmdline or util.get('value', data) is None:
         return httpsvc.ResponseBody.BAD_REQUEST
     await proch.PipeInLineService.request(self.mailer, self,
                                           cmdline.build())
     return httpsvc.ResponseBody.NO_CONTENT
Example #2
0
def steamcmd_app_update(**kwargs):
    line = [
        '+login anonymous', '+force_install_dir {install_dir}',
        '+app_update {app_id}'
    ]
    if util.get('beta', kwargs):
        line.append('-beta {beta}')
    if util.get('validate', kwargs):
        line.append('validate')
    line.append('+quit')
    line = ' '.join(line).format(**kwargs)
    return util.to_text(
        (_function_find_steamcmd(), '$(find_steamcmd) ' + line))
Example #3
0
 def add_player(self, player):
     names = util.get(player.get_steamid(), self.data)
     if names:
         if player.get_name() not in names:
             names.append(player.get_name())
     else:
         self.data.update({player.get_steamid(): [player.get_name()]})
Example #4
0
 def build(self, args=None, output=str):
     assert output in (str, list)
     args = {**self.args, **args} if args else self.args
     cmdline = []
     for part in iter(self.command):
         if isinstance(part, (str, int, float)):
             part_str = str(part)
             if util.is_format(part_str):
                 cmdline.append(part_str.format(**args))
             else:
                 cmdline.append(part_str)
         elif isinstance(part, dict):
             for arg_key, arg_format in iter(part.items()):
                 arg_format = str(arg_format).replace('%s', '{}')
                 if util.is_format(arg_format):
                     value = util.get(arg_key, args)
                     if isinstance(value, list):
                         cmdline.append(arg_format.format(*value))
                     elif value:
                         cmdline.append(arg_format.format(value))
                 elif arg_key in args:
                     cmdline.append(arg_format)
     if output is list:
         return cmdline
     return ' '.join(cmdline)
Example #5
0
 async def handle_get(self, resource, data):
     subscriber = self.service.lookup(util.get('identity', data))
     if subscriber is None:
         return httpsvc.ResponseBody.NOT_FOUND
     result = await subscriber.get()
     if result is None:
         return httpsvc.ResponseBody.NO_CONTENT
     return result
Example #6
0
 async def handle_post(self, resource, data):
     command = util.get('command', data)
     if command == 'backup-world':
         return {'file': self.deployment.backup_world()}
     if command == 'wipe-world-all':
         self.deployment.wipe_world_all()
         return httpsvc.ResponseBody.NO_CONTENT
     if command == 'wipe-world-playerdb':
         self.deployment.wipe_world_playerdb()
         return httpsvc.ResponseBody.NO_CONTENT
     if command == 'wipe-world-config':
         self.deployment.wipe_world_config()
         return httpsvc.ResponseBody.NO_CONTENT
     if command == 'wipe-world-save':
         self.deployment.wipe_world_save()
         return httpsvc.ResponseBody.NO_CONTENT
     if command == 'backup-runtime':
         return {'file': self.deployment.backup_runtime()}
     if command == 'install-runtime':
         return await self.deployment.install_runtime(
             beta=util.get('beta', data),
             validate=util.get('validate', data))
     return httpsvc.ResponseBody.NOT_FOUND
Example #7
0
 def config(self, key):
     value = util.get(key, self.configuration)
     if value is not None or self.parent is None:
         return value
     return self.parent.config(value)
Example #8
0
 async def handle_post(self, resource, data):
     command = util.get('command', data)
     if command is None or command not in ServerCommandHandler.COMMANDS:
         return httpsvc.ResponseBody.BAD_REQUEST
     ServerCommandHandler.COMMANDS[command](self.mailer, self)
     return httpsvc.ResponseBody.NO_CONTENT
Example #9
0
 def lookup(self, identity):
     return util.get(identity, self.subscriptions)
Example #10
0
 def get(self, args, command_key=None):
     if command_key is None:
         command_key = self.command_key
     command = util.get(util.get(command_key, args), self.commands)
     return None if not command else CommandLine(command, args)
Example #11
0
 def handle(self, message):
     state = util.get(message.get_name(), ServerStateSubscriber.STATE_MAP)
     state = state if state else 'UNKNOWN'
     svrsvc.ServerStatus.notify_state(self.mailer, self, state)