2525import re
2626
2727import odooly
28- import requests
2928
3029RUNBOT_HOST = "runbot.odoo.com"
3130RUNBOT_URL = f"https://{ RUNBOT_HOST } /runbot/submit?update_triggers=1&trigger_1=on&trigger_122=on"
4039
4140def _retrieve_servers (url = RUNBOT_URL , regex = RUNBOT_REGEX , user = DEFAULT_USER ):
4241 test_servers = collections .defaultdict (set )
43- overview = requests . get ( url )
44- builds = re .findall (regex , overview . text , re .DOTALL )
42+ overview = odooly . HTTPSession (). request ( url , method = 'GET' )
43+ builds = re .findall (regex , overview , re .DOTALL )
4544 for edition , odoo_url , build , ver in builds :
4645 suffix = "+e" if edition == "Enterprise" else ""
4746 if "saas" in ver :
@@ -68,23 +67,31 @@ def main():
6867 parser = optparse .OptionParser (usage = '%prog [options] ENV' , description = description )
6968 parser .add_option ('-u' , '--user' , default = DEFAULT_USER , help = '\' demo\' or \' admin\' ' )
7069 parser .add_option ('-v' , '--verbose' , default = 0 , action = 'count' , help = 'verbose' )
70+ parser .add_option ('-c' , '--config' , default = None )
71+ parser .add_option ('--api-key' , dest = 'api_key' , default = None , help = 'API Key' )
7172
7273 [opts , args ] = parser .parse_args ()
7374 [version ] = args or ['demo' ]
7475
76+ if opts .config :
77+ odooly .Client ._config_file = odooly .Path .cwd () / opts .config
7578 _retrieve_servers (user = opts .user )
76-
77- print ("Available Odoo builds: " + ", " .join (ODOO_SERVERS ))
78- try :
79- while version not in ODOO_SERVERS :
80- version = input ("Choose one: " )
81- except KeyboardInterrupt :
82- raise SystemExit ("" )
83-
84- print (f"Connect to Odoo { version } ..." )
8579 global_vars = odooly .Client ._set_interactive ()
8680 global_vars ['__doc__' ] = __doc__
87- odooly .Client .from_config (version , user = opts .user , verbose = opts .verbose )
81+
82+ if version .startswith ('http' ):
83+ print (f"Connect to { version } ..." )
84+ odooly .Client (version , user = opts .user , api_key = opts .api_key , verbose = opts .verbose )
85+ else :
86+ print ("Available Odoo builds: " + ", " .join (ODOO_SERVERS ))
87+ try :
88+ while version not in ODOO_SERVERS :
89+ version = input ("Choose one: " )
90+ except (KeyboardInterrupt , EOFError ):
91+ raise SystemExit ("" )
92+ print (f"Connect to Odoo { version } ..." )
93+ odooly .Client .from_config (version , user = opts .user , verbose = opts .verbose )
94+
8895 odooly ._interact (global_vars )
8996
9097
0 commit comments