diff options
| author | 2011-12-19 23:10:49 +0100 | |
|---|---|---|
| committer | 2011-12-19 23:10:49 +0100 | |
| commit | 6eae782f13953dd0ba2bbe1b582cf33fd4d7d90a (patch) | |
| tree | a7e80bc89b1a523854e1f3e3d9ec945023193212 /module/remote/thriftbackend | |
| parent | pluginmanager cleanup (diff) | |
| download | pyload-6eae782f13953dd0ba2bbe1b582cf33fd4d7d90a.tar.xz | |
configparser v2, warning CONFIG will be DELETED.
Diffstat (limited to 'module/remote/thriftbackend')
| -rw-r--r-- | module/remote/thriftbackend/pyload.thrift | 39 | ||||
| -rwxr-xr-x | module/remote/thriftbackend/thriftgen/pyload/Pyload-remote | 23 | ||||
| -rw-r--r-- | module/remote/thriftbackend/thriftgen/pyload/Pyload.py | 152 | ||||
| -rw-r--r-- | module/remote/thriftbackend/thriftgen/pyload/ttypes.py | 140 | 
4 files changed, 227 insertions, 127 deletions
diff --git a/module/remote/thriftbackend/pyload.thrift b/module/remote/thriftbackend/pyload.thrift index 1542e651a..ace24e709 100644 --- a/module/remote/thriftbackend/pyload.thrift +++ b/module/remote/thriftbackend/pyload.thrift @@ -93,20 +93,6 @@ struct ServerStatus {    7: bool reconnect  } -struct ConfigItem { -  1: string name, -  2: string description, -  3: string value, -  4: string type, -} - -struct ConfigSection { -  1: string name, -  2: string description, -  3: list<ConfigItem> items, -  4: optional string outline -} -  struct FileData {    1: FileID fid,    2: string url, @@ -149,6 +135,24 @@ struct InteractionTask {    9: string plugin,  } +struct ConfigItem { +  1: string name, +  2: string long_name, +  3: string description, +  4: string type, +  5: string default_value, +  6: string value, +} + +struct ConfigSection { +  1: string name, +  2: string long_name, +  3: string description, +  4: string long_description, +  5: optional list<ConfigItem> items, +  6: optional map<string, InteractionTask> handler, +} +  struct CaptchaTask {    1: i16 tid,    2: binary data, @@ -225,10 +229,11 @@ exception ServiceException{  service Pyload {    //config -  string getConfigValue(1: string category, 2: string option, 3: string section), -  void setConfigValue(1: string category, 2: string option, 3: string value, 4: string section), +  string getConfigValue(1: string section, 2: string option), +  void setConfigValue(1: string section, 2: string option, 3: string value),    map<string, ConfigSection> getConfig(), -  map<string, ConfigSection> getPluginConfig(), +  map<PluginName, ConfigSection> getPluginConfig(), +  ConfigSection configureSection(1: string section),    // server status    void pauseServer(), diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote index bfaf5b078..f8bcc2863 100755 --- a/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote +++ b/module/remote/thriftbackend/thriftgen/pyload/Pyload-remote @@ -23,10 +23,11 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':    print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'    print ''    print 'Functions:' -  print '  string getConfigValue(string category, string option, string section)' -  print '  void setConfigValue(string category, string option, string value, string section)' +  print '  string getConfigValue(string section, string option)' +  print '  void setConfigValue(string section, string option, string value)'    print '   getConfig()'    print '   getPluginConfig()' +  print '  ConfigSection configureSection(string section)'    print '  void pauseServer()'    print '  void unpauseServer()'    print '  bool togglePause()' @@ -145,16 +146,16 @@ client = Pyload.Client(protocol)  transport.open()  if cmd == 'getConfigValue': -  if len(args) != 3: -    print 'getConfigValue requires 3 args' +  if len(args) != 2: +    print 'getConfigValue requires 2 args'      sys.exit(1) -  pp.pprint(client.getConfigValue(args[0],args[1],args[2],)) +  pp.pprint(client.getConfigValue(args[0],args[1],))  elif cmd == 'setConfigValue': -  if len(args) != 4: -    print 'setConfigValue requires 4 args' +  if len(args) != 3: +    print 'setConfigValue requires 3 args'      sys.exit(1) -  pp.pprint(client.setConfigValue(args[0],args[1],args[2],args[3],)) +  pp.pprint(client.setConfigValue(args[0],args[1],args[2],))  elif cmd == 'getConfig':    if len(args) != 0: @@ -168,6 +169,12 @@ elif cmd == 'getPluginConfig':      sys.exit(1)    pp.pprint(client.getPluginConfig()) +elif cmd == 'configureSection': +  if len(args) != 1: +    print 'configureSection requires 1 args' +    sys.exit(1) +  pp.pprint(client.configureSection(args[0],)) +  elif cmd == 'pauseServer':    if len(args) != 0:      print 'pauseServer requires 0 args' diff --git a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py index 78a42f16a..1e2f78b66 100644 --- a/module/remote/thriftbackend/thriftgen/pyload/Pyload.py +++ b/module/remote/thriftbackend/thriftgen/pyload/Pyload.py @@ -13,22 +13,20 @@ from thrift.protocol.TBase import TBase, TExceptionBase  class Iface(object): -  def getConfigValue(self, category, option, section): +  def getConfigValue(self, section, option):      """      Parameters: -     - category -     - option       - section +     - option      """      pass -  def setConfigValue(self, category, option, value, section): +  def setConfigValue(self, section, option, value):      """      Parameters: -     - category +     - section       - option       - value -     - section      """      pass @@ -38,6 +36,13 @@ class Iface(object):    def getPluginConfig(self, ):      pass +  def configureSection(self, section): +    """ +    Parameters: +     - section +    """ +    pass +    def pauseServer(self, ):      pass @@ -434,22 +439,20 @@ class Client(Iface):        self._oprot = oprot      self._seqid = 0 -  def getConfigValue(self, category, option, section): +  def getConfigValue(self, section, option):      """      Parameters: -     - category -     - option       - section +     - option      """ -    self.send_getConfigValue(category, option, section) +    self.send_getConfigValue(section, option)      return self.recv_getConfigValue() -  def send_getConfigValue(self, category, option, section): +  def send_getConfigValue(self, section, option):      self._oprot.writeMessageBegin('getConfigValue', TMessageType.CALL, self._seqid)      args = getConfigValue_args() -    args.category = category -    args.option = option      args.section = section +    args.option = option      args.write(self._oprot)      self._oprot.writeMessageEnd()      self._oprot.trans.flush() @@ -468,24 +471,22 @@ class Client(Iface):        return result.success      raise TApplicationException(TApplicationException.MISSING_RESULT, "getConfigValue failed: unknown result"); -  def setConfigValue(self, category, option, value, section): +  def setConfigValue(self, section, option, value):      """      Parameters: -     - category +     - section       - option       - value -     - section      """ -    self.send_setConfigValue(category, option, value, section) +    self.send_setConfigValue(section, option, value)      self.recv_setConfigValue() -  def send_setConfigValue(self, category, option, value, section): +  def send_setConfigValue(self, section, option, value):      self._oprot.writeMessageBegin('setConfigValue', TMessageType.CALL, self._seqid)      args = setConfigValue_args() -    args.category = category +    args.section = section      args.option = option      args.value = value -    args.section = section      args.write(self._oprot)      self._oprot.writeMessageEnd()      self._oprot.trans.flush() @@ -552,6 +553,36 @@ class Client(Iface):        return result.success      raise TApplicationException(TApplicationException.MISSING_RESULT, "getPluginConfig failed: unknown result"); +  def configureSection(self, section): +    """ +    Parameters: +     - section +    """ +    self.send_configureSection(section) +    return self.recv_configureSection() + +  def send_configureSection(self, section): +    self._oprot.writeMessageBegin('configureSection', TMessageType.CALL, self._seqid) +    args = configureSection_args() +    args.section = section +    args.write(self._oprot) +    self._oprot.writeMessageEnd() +    self._oprot.trans.flush() + +  def recv_configureSection(self, ): +    (fname, mtype, rseqid) = self._iprot.readMessageBegin() +    if mtype == TMessageType.EXCEPTION: +      x = TApplicationException() +      x.read(self._iprot) +      self._iprot.readMessageEnd() +      raise x +    result = configureSection_result() +    result.read(self._iprot) +    self._iprot.readMessageEnd() +    if result.success is not None: +      return result.success +    raise TApplicationException(TApplicationException.MISSING_RESULT, "configureSection failed: unknown result"); +    def pauseServer(self, ):      self.send_pauseServer()      self.recv_pauseServer() @@ -2427,6 +2458,7 @@ class Processor(Iface, TProcessor):      self._processMap["setConfigValue"] = Processor.process_setConfigValue      self._processMap["getConfig"] = Processor.process_getConfig      self._processMap["getPluginConfig"] = Processor.process_getPluginConfig +    self._processMap["configureSection"] = Processor.process_configureSection      self._processMap["pauseServer"] = Processor.process_pauseServer      self._processMap["unpauseServer"] = Processor.process_unpauseServer      self._processMap["togglePause"] = Processor.process_togglePause @@ -2514,7 +2546,7 @@ class Processor(Iface, TProcessor):      args.read(iprot)      iprot.readMessageEnd()      result = getConfigValue_result() -    result.success = self._handler.getConfigValue(args.category, args.option, args.section) +    result.success = self._handler.getConfigValue(args.section, args.option)      oprot.writeMessageBegin("getConfigValue", TMessageType.REPLY, seqid)      result.write(oprot)      oprot.writeMessageEnd() @@ -2525,7 +2557,7 @@ class Processor(Iface, TProcessor):      args.read(iprot)      iprot.readMessageEnd()      result = setConfigValue_result() -    self._handler.setConfigValue(args.category, args.option, args.value, args.section) +    self._handler.setConfigValue(args.section, args.option, args.value)      oprot.writeMessageBegin("setConfigValue", TMessageType.REPLY, seqid)      result.write(oprot)      oprot.writeMessageEnd() @@ -2553,6 +2585,17 @@ class Processor(Iface, TProcessor):      oprot.writeMessageEnd()      oprot.trans.flush() +  def process_configureSection(self, seqid, iprot, oprot): +    args = configureSection_args() +    args.read(iprot) +    iprot.readMessageEnd() +    result = configureSection_result() +    result.success = self._handler.configureSection(args.section) +    oprot.writeMessageBegin("configureSection", TMessageType.REPLY, seqid) +    result.write(oprot) +    oprot.writeMessageEnd() +    oprot.trans.flush() +    def process_pauseServer(self, seqid, iprot, oprot):      args = pauseServer_args()      args.read(iprot) @@ -3302,28 +3345,24 @@ class Processor(Iface, TProcessor):  class getConfigValue_args(TBase):    """    Attributes: -   - category -   - option     - section +   - option    """    __slots__ = [  -    'category', -    'option',      'section', +    'option',     ]    thrift_spec = (      None, # 0 -    (1, TType.STRING, 'category', None, None, ), # 1 +    (1, TType.STRING, 'section', None, None, ), # 1      (2, TType.STRING, 'option', None, None, ), # 2 -    (3, TType.STRING, 'section', None, None, ), # 3    ) -  def __init__(self, category=None, option=None, section=None,): -    self.category = category -    self.option = option +  def __init__(self, section=None, option=None,):      self.section = section +    self.option = option  class getConfigValue_result(TBase): @@ -3347,32 +3386,28 @@ class getConfigValue_result(TBase):  class setConfigValue_args(TBase):    """    Attributes: -   - category +   - section     - option     - value -   - section    """    __slots__ = [  -    'category', +    'section',      'option',      'value', -    'section',     ]    thrift_spec = (      None, # 0 -    (1, TType.STRING, 'category', None, None, ), # 1 +    (1, TType.STRING, 'section', None, None, ), # 1      (2, TType.STRING, 'option', None, None, ), # 2      (3, TType.STRING, 'value', None, None, ), # 3 -    (4, TType.STRING, 'section', None, None, ), # 4    ) -  def __init__(self, category=None, option=None, value=None, section=None,): -    self.category = category +  def __init__(self, section=None, option=None, value=None,): +    self.section = section      self.option = option      self.value = value -    self.section = section  class setConfigValue_result(TBase): @@ -3438,6 +3473,43 @@ class getPluginConfig_result(TBase):      self.success = success +class configureSection_args(TBase): +  """ +  Attributes: +   - section +  """ + +  __slots__ = [  +    'section', +   ] + +  thrift_spec = ( +    None, # 0 +    (1, TType.STRING, 'section', None, None, ), # 1 +  ) + +  def __init__(self, section=None,): +    self.section = section + + +class configureSection_result(TBase): +  """ +  Attributes: +   - success +  """ + +  __slots__ = [  +    'success', +   ] + +  thrift_spec = ( +    (0, TType.STRUCT, 'success', (ConfigSection, ConfigSection.thrift_spec), None, ), # 0 +  ) + +  def __init__(self, success=None,): +    self.success = success + +  class pauseServer_args(TBase):    __slots__ = [  diff --git a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py index 1299b515d..3ccca992b 100644 --- a/module/remote/thriftbackend/thriftgen/pyload/ttypes.py +++ b/module/remote/thriftbackend/thriftgen/pyload/ttypes.py @@ -270,68 +270,6 @@ class ServerStatus(TBase):      self.reconnect = reconnect -class ConfigItem(TBase): -  """ -  Attributes: -   - name -   - description -   - value -   - type -  """ - -  __slots__ = [  -    'name', -    'description', -    'value', -    'type', -   ] - -  thrift_spec = ( -    None, # 0 -    (1, TType.STRING, 'name', None, None, ), # 1 -    (2, TType.STRING, 'description', None, None, ), # 2 -    (3, TType.STRING, 'value', None, None, ), # 3 -    (4, TType.STRING, 'type', None, None, ), # 4 -  ) - -  def __init__(self, name=None, description=None, value=None, type=None,): -    self.name = name -    self.description = description -    self.value = value -    self.type = type - - -class ConfigSection(TBase): -  """ -  Attributes: -   - name -   - description -   - items -   - outline -  """ - -  __slots__ = [  -    'name', -    'description', -    'items', -    'outline', -   ] - -  thrift_spec = ( -    None, # 0 -    (1, TType.STRING, 'name', None, None, ), # 1 -    (2, TType.STRING, 'description', None, None, ), # 2 -    (3, TType.LIST, 'items', (TType.STRUCT,(ConfigItem, ConfigItem.thrift_spec)), None, ), # 3 -    (4, TType.STRING, 'outline', None, None, ), # 4 -  ) - -  def __init__(self, name=None, description=None, items=None, outline=None,): -    self.name = name -    self.description = description -    self.items = items -    self.outline = outline - -  class FileData(TBase):    """    Attributes: @@ -509,6 +447,84 @@ class InteractionTask(TBase):      self.plugin = plugin +class ConfigItem(TBase): +  """ +  Attributes: +   - name +   - long_name +   - description +   - type +   - default_value +   - value +  """ + +  __slots__ = [  +    'name', +    'long_name', +    'description', +    'type', +    'default_value', +    'value', +   ] + +  thrift_spec = ( +    None, # 0 +    (1, TType.STRING, 'name', None, None, ), # 1 +    (2, TType.STRING, 'long_name', None, None, ), # 2 +    (3, TType.STRING, 'description', None, None, ), # 3 +    (4, TType.STRING, 'type', None, None, ), # 4 +    (5, TType.STRING, 'default_value', None, None, ), # 5 +    (6, TType.STRING, 'value', None, None, ), # 6 +  ) + +  def __init__(self, name=None, long_name=None, description=None, type=None, default_value=None, value=None,): +    self.name = name +    self.long_name = long_name +    self.description = description +    self.type = type +    self.default_value = default_value +    self.value = value + + +class ConfigSection(TBase): +  """ +  Attributes: +   - name +   - long_name +   - description +   - long_description +   - items +   - handler +  """ + +  __slots__ = [  +    'name', +    'long_name', +    'description', +    'long_description', +    'items', +    'handler', +   ] + +  thrift_spec = ( +    None, # 0 +    (1, TType.STRING, 'name', None, None, ), # 1 +    (2, TType.STRING, 'long_name', None, None, ), # 2 +    (3, TType.STRING, 'description', None, None, ), # 3 +    (4, TType.STRING, 'long_description', None, None, ), # 4 +    (5, TType.LIST, 'items', (TType.STRUCT,(ConfigItem, ConfigItem.thrift_spec)), None, ), # 5 +    (6, TType.MAP, 'handler', (TType.STRING,None,TType.STRUCT,(InteractionTask, InteractionTask.thrift_spec)), None, ), # 6 +  ) + +  def __init__(self, name=None, long_name=None, description=None, long_description=None, items=None, handler=None,): +    self.name = name +    self.long_name = long_name +    self.description = description +    self.long_description = long_description +    self.items = items +    self.handler = handler + +  class CaptchaTask(TBase):    """    Attributes:  | 
