threefoldtecharchive / jumpscaleX_threebot

Apache License 2.0
0 stars 3 forks source link

Check for toml file before creating package instances #593

Closed abom closed 4 years ago

abom commented 4 years ago

When installing a package with a wrong path via package_manager actor or j.tools.threebot_packages or even from the dashboard, we cannot deal with it later, because it checks for the package.toml in _init method.

This need to be refactored, factory should have something like from_toml or so, instead of checking for the package.toml file after getting an instance.

3BOTDEVEL:3bot:~: kosmos -p                                                                                                                          
JSX> j.tools.threebot_packages.get("aa.bb")                                                                                                          
Fri 17 15:04:20 e/ThreeBotPackage.py - 307 - config_load                        : EXCEPTION:                                                         
    cannot find config file in path /package.toml for package aa.bb                                                                                  
--TRACEBACK------------------                                                                                                                        
<stdin> in <module>                                                                                                                                  
    1
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in get
    120    jsconfig = self._create(name=name, **kwargs)
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in _create
    96    jsconfig = jsconfig_klass(parent=self, jsxobject=jsxobject, **kwargs_to_class)
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSBase.py in __init__
    66    self._init(**kwargs)
/sandbox/lib/jumpscale/Jumpscale/tools/threebot_package/ThreeBotPackageBase.py in _init
    12    self.config_load()
/sandbox/lib/jumpscale/Jumpscale/tools/threebot_package/ThreeBotPackage.py in config_load
    307    raise j.exceptions.Input(f"cannot find config file in path {tomlfile} for package {self.name}")
-----------------------------

Even when trying to delete it:

JSX> j.tools.threebot_packages.delete("aa.bb")                                                                                                       
Fri 17 15:05:14 e/ThreeBotPackage.py - 307 - config_load                        : EXCEPTION:                                                         
    cannot find config file in path /package.toml for package aa.bb                                                                                  
--TRACEBACK------------------                                                                                                                        
<stdin> in <module>                                                                                                                                  
    1                                                                                                                                                
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in delete                                                                         
    302    self._delete(name=name)                                                                                                                   
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in _delete                                                                        
    306    child = self._get(name=name, die=False)                                                                                                   
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in _get                                                                           
    179    res = self.find(name=name)                                                                                                                
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in find                                                                           
    263    item = self.get(id=id, reload=reload)                                                                                                     
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in get                                                                            
    116    jsconfig = self._get(name=name, id=id, die=needexist, reload=reload)                                                                      
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in _get                                                                           
    171    return self._create(name, obj)                                                                                                            
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSConfigsBCDB.py in _create                                                                        
    96    jsconfig = jsconfig_klass(parent=self, jsxobject=jsxobject, **kwargs_to_class)                                                             
/sandbox/lib/jumpscale/Jumpscale/core/BASECLASSES/JSBase.py in __init__                                                                              
    66    self._init(**kwargs)                                                                                                                       
/sandbox/lib/jumpscale/Jumpscale/tools/threebot_package/ThreeBotPackageBase.py in _init                                                              
    12    self.config_load()                                                                                                                         
/sandbox/lib/jumpscale/Jumpscale/tools/threebot_package/ThreeBotPackage.py in config_load                                                            
    307    raise j.exceptions.Input(f"cannot find config file in path {tomlfile} for package {self.name}")
-----------------------------
waleedhammam commented 4 years ago

PR at: https://github.com/threefoldtech/jumpscaleX_core/pull/811

Scenarios

Dina-Abd-Elrahman commented 4 years ago