def exists(self):
     try:
         options = dict(uuid=self.UUID)
         result = db.select('work', options, where="work_id = $uuid")
         return result.first()["work_id"] == self.UUID
     except BaseException:
         return False
 def exists(self):
     try:
         where = "%s = $%s" % (self.table_name, self.table_name)
         result = db.select(self.table_name, self.__dict__, where=where)
         candidate = self.__dict__[self.table_name]
         return result.first()[self.table_name] == candidate
     except BaseException:
         return False
 def get(self, table_id=''):
     """Returns the list of samples in the table with the given ID
     """
     con = db.get_engine(bind='summarization')
     tbl = SummarizationGeneExpressionUtils.get_table_object(table_id)
     values = []
     try:
         rows = con.execute(db.select([tbl.c.Sample]).distinct())
     except SQLAlchemyError:
         return BARUtils.error_exit('Internal server error'), 500
     [values.append(row.Sample) for row in rows]
     return BARUtils.success_exit(values)
 def get(self, table_id='', user_string=''):
     """Returns all genes that contain a given string as part of their name
     """
     con = db.get_engine(bind='summarization')
     tbl = SummarizationGeneExpressionUtils.get_table_object(table_id)
     values = []
     try:
         rows = con.execute(
             db.select([tbl.c.Gene]).where(
                 tbl.c.Gene.contains(user_string)).distinct())
     except SQLAlchemyError:
         return BARUtils.error_exit('Internal server error'), 500
     [values.append(row.Gene) for row in rows]
     return BARUtils.success_exit(values)
 def get(self, table_id=''):
     """Returns the list of genes in the table with the given ID
     """
     key = request.headers.get('x-api-key')
     if SummarizationGeneExpressionUtils.decrement_uses(key):
         con = db.get_engine(bind='summarization')
         tbl = SummarizationGeneExpressionUtils.get_table_object(table_id)
         values = []
         try:
             rows = con.execute(db.select([tbl.c.Gene]).distinct())
         except SQLAlchemyError:
             return BARUtils.error_exit('Internal server error'), 500
         [values.append(row.Gene) for row in rows]
         return BARUtils.success_exit(values)
     else:
         return BARUtils.error_exit('Invalid API key')
Esempio n. 6
0
File: probe.py Progetto: niximor/mon
    def get(self):
        """
        List of probes.
        """
        session = config.session()
        try:
            query = select(session, request.args.getlist("show"),
                           self.SELECT_COLUMN_MAPPING,
                           self.SELECT_JOIN_MAPPING,
                           self.TABLE_JOINS).order_by(entity.Probe.name)

            result = [probe._asdict() for probe in query.all()]
            logging.info(result)
            return result
        finally:
            session.commit()
 def validate_api_key(key):
     """Checks if a given API key is in the Users database
     :param key: The API key to be checked
     """
     tbl = SummarizationGeneExpressionUtils.get_table_object('users')
     con = db.get_engine(bind='summarization')
     try:
         row = con.execute(
             db.select([tbl.c.uses_left
                        ]).where(tbl.c.api_key == key)).first()
     except SQLAlchemyError as e:
         error = str(e.__dict__['orig'])
         return error
     if row is None:
         return False
     else:
         if row.uses_left > 0:
             return True
         else:
             return False
 def get_all():
     return db.select(UriScheme.table_name)
Esempio n. 9
0
 def get_all():
     return db.select(WorkType.table_name)
 def get_relatives(self, key):
     where = {"parent_work_id": "child_work_id=$uuid",
              "child_work_id": "parent_work_id=$uuid"}
     options = dict(uuid=self.UUID)
     return db.select('work_relation', options, what=key, where=where[key])
 def get_identifiers(self):
     options = dict(uuid=self.UUID)
     uris = db.select('work_uri', options,
                      what="uri_scheme, uri_value, canonical",
                      where="work_id = $uuid")
     return results_to_identifiers(uris)
 def get_titles(self):
     options = dict(uuid=self.UUID)
     titles = db.select('work_title', options,
                        what="title", where="work_id = $uuid")
     return [(x["title"]) for x in titles] if titles else []
 def get_type(self):
     options = dict(uuid=self.UUID)
     result = db.select('work', options,
                        what="work_type", where="work_id = $uuid")
     return result.first()["work_type"] if result else None
Esempio n. 14
0
 def get_all():
     return db.select('title')
Esempio n. 15
0
 def get_from_email(email):
     options = dict(email=email)
     return db.select('account', options, where="email = $email")
Esempio n. 16
0
 def get_all():
     try:
         return db.select('measure')
     except (Exception, psycopg2.DatabaseError) as error:
         logger.error(error)
         raise Error(FATAL)