@@ -136,7 +136,8 @@ def __init__(self, name, description, can_be_submitted_to_ebi,
136136
137137
138138class BaseQiitaPlugin (object ):
139- def __init__ (self , name , version , description , publications = None , plugincoupling = 'filesystem' ):
139+ _ALLOWED_PLUGIN_COUPLINGS = ['filesystem' , 'https' ] # default must be first element
140+ def __init__ (self , name , version , description , publications = None , plugincoupling = _ALLOWED_PLUGIN_COUPLINGS [0 ]):
140141 logger .debug ('Entered BaseQiitaPlugin.__init__()' )
141142 self .name = name
142143 self .version = version
@@ -160,6 +161,8 @@ def __init__(self, name, version, description, publications=None, plugincoupling
160161 # Actually, all files need to be decorated with this function. The decision how
161162 # data are transferred is then made within these two functions according to the
162163 # "plugincoupling" setting.
164+ if plugincoupling not in self ._ALLOWED_PLUGIN_COUPLINGS :
165+ raise ValueError ("valid plugincoupling values are ['%s'], but you provided %s" % ("', '" .join (self ._ALLOWED_PLUGIN_COUPLINGS ), plugincoupling ))
163166 self .plugincoupling = plugincoupling
164167
165168 # Will hold the different commands
@@ -170,7 +173,7 @@ def __init__(self, name, version, description, publications=None, plugincoupling
170173 'QIITA_PLUGINS_DIR' , join (expanduser ('~' ), '.qiita_plugins' ))
171174 self .conf_fp = join (conf_dir , "%s_%s.conf" % (self .name , self .version ))
172175
173- def generate_config (self , env_script , start_script , server_cert = None ):
176+ def generate_config (self , env_script , start_script , server_cert = None , plugin_couling = _ALLOWED_PLUGIN_COUPLINGS [ 0 ] ):
174177 """Generates the plugin configuration file
175178
176179 Parameters
@@ -184,6 +187,9 @@ def generate_config(self, env_script, start_script, server_cert=None):
184187 If the Qiita server used does not have a valid certificate, the
185188 path to the Qiita certificate so the plugin can connect over
186189 HTTPS to it
190+ plugin_coupling : str
191+ Type of coupling of plugin to central for file exchange.
192+ Valid values are 'filesystem' and 'https'.
187193 """
188194 logger .debug ('Entered BaseQiitaPlugin.generate_config()' )
189195 sr = SystemRandom ()
@@ -198,7 +204,7 @@ def generate_config(self, env_script, start_script, server_cert=None):
198204 env_script , start_script ,
199205 self ._plugin_type , self .publications ,
200206 server_cert , client_id , client_secret ,
201- self . plugincoupling ))
207+ plugin_couling ))
202208
203209 def _register_command (self , command ):
204210 """Registers a command in the plugin
@@ -208,8 +214,7 @@ def _register_command(self, command):
208214 command: QiitaCommand
209215 The command to be added to the plugin
210216 """
211- logger .debug (
212- f'Entered BaseQiitaPlugin._register_command({ command .name } )' )
217+ logger .debug ('Entered BaseQiitaPlugin._register_command(%s)' % command .name )
213218 self .task_dict [command .name ] = command
214219
215220 def _register (self , qclient ):
@@ -271,7 +276,8 @@ def __call__(self, server_url, job_id, output_dir):
271276 # this value will prevent underlying libraries
272277 # from validating the server's cert using
273278 # certifi's pem cache.
274- ca_cert = config .get ('oauth2' , 'SERVER_CERT' ))
279+ ca_cert = config .get ('oauth2' , 'SERVER_CERT' ),
280+ plugincoupling = config .get ('network' , 'PLUGINCOUPLING' ))
275281
276282 if job_id == 'register' :
277283 self ._register (qclient )
@@ -335,7 +341,7 @@ class QiitaTypePlugin(BaseQiitaPlugin):
335341
336342 def __init__ (self , name , version , description , validate_func ,
337343 html_generator_func , artifact_types , publications = None ,
338- plugincoupling = 'filesystem' ):
344+ plugincoupling = BaseQiitaPlugin . _ALLOWED_PLUGIN_COUPLINGS [ 0 ] ):
339345 super (QiitaTypePlugin , self ).__init__ (name , version , description ,
340346 publications = publications ,
341347 plugincoupling = plugincoupling )
@@ -400,9 +406,12 @@ def register_command(self, command):
400406START_SCRIPT = %s
401407PLUGIN_TYPE = %s
402408PUBLICATIONS = %s
403- PLUGINCOUPLING = %s
404409
405410[oauth2]
406411SERVER_CERT = %s
407412CLIENT_ID = %s
408- CLIENT_SECRET = %s"""
413+ CLIENT_SECRET = %s
414+
415+ [network]
416+ PLUGINCOUPLING = %s
417+ """
0 commit comments