def __init__(self, section='', user=None, passwd=None, quiet=False, refresh=False): """ Creates a connection to the DB as easyaccess commands, section is obtained from config file, can be bypass here, e.g., section = desoper Parameters: ----------- section : DB connection : dessci, desoper, destest user : Manualy use username passwd : password for username (if not enter is prompted) quiet : Don't print much Returns: -------- easy_or object """ self.quiet = quiet conf = config_mod.get_config(config_file) self.conf = conf pd.set_option('display.max_rows', conf.getint('display', 'max_rows')) pd.set_option('display.width', conf.getint('display', 'width')) pd.set_option('display.max_columns', conf.getint('display', 'max_columns')) pd.set_option('display.max_colwidth', conf.getint('display', 'max_colwidth')) if section == '': db = conf.get('easyaccess', 'database') else: db = section if user is not None: print('Bypassing .desservices file with user : %s' % user) if passwd is None: passwd = getpass.getpass(prompt='Enter password : '******'db-' + db, 'user', user) desconf.set('db-' + db, 'passwd', passwd) else: desconf = config_mod.get_desconfig(desfile, db) easy_or.__init__(self, conf, desconf, db, interactive=False, quiet=quiet, pymod=True) try: self.cur.execute('create table FGOTTENMETADATA (ID int)') except: pass self.loading_bar = False
def __init__(self, user=None, token=None, root_url=None, db='desoper', verbose=False): passwd = None self.desconf = config_mod.get_desconfig(DESFILE, db) self._db = db self.verbose = verbose self.jobid = None self.token = None self.submit = None self._status = None self.job = None self.links = None self.files = [] if user is not None: if self.verbose: print('Bypassing .desservices file with user : %s' % user) if passwd is None: passwd = getpass.getpass(prompt='Enter password : '******'db-' + self._db, 'user', user) self.desconf.set('db-' + self._db, 'passwd', passwd) self.user = self.desconf.get('db-' + self._db, 'user') self._passwd = self.desconf.get('db-' + self._db, 'passwd') self.root_url = root_url.strip('/') self.get_token() self.jobs_info = requests.get( self.root_url + '/api/jobs/?token=%s&list_jobs' % self.token).json() self._jobs = [Job(j, self.user, self.token, self.root_url) for j in self.jobs_info['list_jobs']] self.creation_times = self.jobs_info['creation_time'] self.job_types = self.jobs_info['job_type']
def __init__(self, user=None, root_url='https://desar2.cosmology.illinois.edu/DESFiles/desarchive/', db='desoper', verbose=True): passwd = None self.desconf = config_mod.get_desconfig(DESFILE, db) self._db = db self.verbose = verbose self.links = [] self.files = [] if user is not None: if self.verbose: print('Bypassing .desservices file with user : %s' % user) if passwd is None: passwd = getpass.getpass(prompt='Enter password : '******'db-' + self._db, 'user', user) self.desconf.set('db-' + self._db, 'passwd', passwd) self.user = self.desconf.get('db-' + self._db, 'user') self._passwd = self.desconf.get('db-' + self._db, 'passwd') self.root_url = root_url self.base_query = """
def __init__(self, user=None, root_url=None, db='desoper', verbose=True): passwd = None self.desconf = config_mod.get_desconfig(DESFILE, db) self._db = db self.verbose = verbose self.jobid = None self.token = None self.submit = None self._status = None self.job = None self.links = None self.files = [] if user is not None: if self.verbose: print('Bypassing .desservices file with user : %s' % user) if passwd is None: passwd = getpass.getpass(prompt='Enter password : '******'db-' + self._db, 'user', user) self.desconf.set('db-' + self._db, 'passwd', passwd) self.user = self.desconf.get('db-' + self._db, 'user') self._passwd = self.desconf.get('db-' + self._db, 'passwd') self.root_url = root_url.strip('/')