Пример #1
0
 def delete_file(self,file_id):
     try:
         mongo_helper=MongodbHelper(self.host,self.port)
         mongo_helper.delete_file(self.db,self.collection, file_id)
         mongo_helper.delete_file(self.default_db,self.default_collection, file_id)
     except Exception as ex:
         SimpleLogger.exception(ex)
Пример #2
0
 def get_field_verbose_name(self, field_name):
     result = ""
     try:
         if field_name:
             result = ProjectIssue._meta.get_field(field_name).verbose_name
     except Exception as ex:
         SimpleLogger.exception(ex)
     return result
Пример #3
0
 def creator_avatar(self):
     result = "/static/global/images/fruit-avatar/Fruit-1.png"
     try:
         creator = User.objects.get(id=self.fortesting.Creator)
         if creator.extend_info:
             result = AccountService.get_avatar_url(creator)
     except Exception as ex:
         SimpleLogger.exception(ex)
     return result
Пример #4
0
 def user_name(self):
     result="系统任务"
     try:
         action_user=User.objects.get(id=self.action_log.User)
         result=action_user.username
         if action_user.last_name and action_user.first_name:
             result=action_user.last_name+action_user.first_name
     except Exception as ex:
         SimpleLogger.exception(ex)
     return result
Пример #5
0
 def delete_file(self, database, collection, file_id):
     client = MongoClient(self.host, self.port)
     try:
         db = client[database]
         bucket_files = GridFSBucket(db, bucket_name=collection)
         bucket_files.delete(ObjectId(file_id))
     except Exception as ex:
         SimpleLogger.exception(ex)
     finally:
         client.close()
Пример #6
0
    def os_name(self):
        result = " "
        try:
            if self.issue.DeviceOS:
                result = ProjectOS.objects.get_byvalue(
                    self.issue.DeviceOS).Name
        except Exception as ex:
            SimpleLogger.exception(ex)

        return result
Пример #7
0
 def fortesting_attachments(self):
     result = list()
     try:
         if self.fortesting.Attachment != None and self.fortesting.Attachment.strip(
         ) != "":
             for file_id in eval(self.fortesting.Attachment):
                 file = FileInfo.objects.get(int(file_id))
                 temp_file = VM_FileInfo(file)
                 result.append(temp_file)
     except Exception as ex:
         SimpleLogger.exception(ex)
     return result
Пример #8
0
 def get_file_bucket(self, database, collection, file_id):
     grid_out = None
     client = MongoClient(self.host, self.port)
     try:
         db = client[database]
         bucket_files = GridFSBucket(db, bucket_name=collection)
         grid_out = bucket_files.open_download_stream(ObjectId(file_id))
     except Exception as ex:
         SimpleLogger.exception(ex)
     finally:
         client.close()
     return grid_out
Пример #9
0
 def get(self, database, collection, doc_id):
     result = None
     client = MongoClient(self.host, self.port)
     try:
         db = client[database]
         collection = db[collection]
         result = collection.find_one({'_id': ObjectId(doc_id)})
     except Exception as ex:
         SimpleLogger.exception(ex)
     finally:
         client.close()
     return result
Пример #10
0
 def remove(self, database, collection, doc_id):
     result = None
     client = MongoClient(self.host, self.port)
     try:
         db = client[database]
         collection = db[collection]
         result = collection.remove(doc_id)
     except Exception as ex:
         SimpleLogger.exception(ex)
     finally:
         client.close()
     return result
Пример #11
0
 def user_avatar(self):
     result="/static/global/images/fruit-avatar/Fruit-1.png"
     try:
         action_user=User.objects.get(id=self.action_log.User)
         if action_user.extend_info:
             result=AccountService.get_avatar_url(action_user)
     except Exception as ex:
         SimpleLogger.exception(ex)
     return result