def __getUserInfo(self,userName,password): base = conf.read_config(conf.path, 'API', 'baseUrl') api = conf.read_config(conf.path, 'API', 'loginApi') url = base + api data = {'name': userName,'password':password} s = requests.session() result = s.post(url,data = data) s.keep_alive = False if result.json() != "error": return result.json()['Table'] else: return "error"
def __getCompetence(self,uid): base = conf.read_config(conf.path, 'API', 'baseUrl') api = conf.read_config(conf.path, 'API', 'getUserRule') url = base + api s = requests.session() idData = { 'ID': uid, 'VALUE': '5' }; result = s.post(url,data = idData) s.keep_alive = False if result.text != u"null": return result.json()['AUTH'] else: return ""
def __addImg(self,data): api = conf.read_config(conf.path, 'API', 'addImgApi') url = base + api s = requests.session() result = s.post(url,data) s.keep_alive = False return result.text
def __getLastVersion(self,entity_id,entity_type): api = conf.read_config(conf.path, 'API', 'getLastVersionApi') url = base + api + '?entity_id=' + entity_id + '&entity_type=' + entity_type s = requests.session() result = s.post(url) s.keep_alive = False return result.content
def __getAssetByType(self,pid): api = conf.read_config(conf.path, 'API', 'getAssetByTypeApi') url = base + api + '?project_id=' + pid s = requests.session() result = s.post(url) s.keep_alive = False return result.json()
def __getTaskStep(self,uid,pid,tableName): api = conf.read_config(conf.path, 'API', 'getTaskStepApi') url = base + api + '?user_id=' + uid + '&project_id='+ pid s = requests.session() result = s.post(url) s.keep_alive = False return result.json()[tableName]
def __upLoadFile(self,filePath,directory): api = conf.read_config(conf.path, 'API', 'publishFileApi') url = base + api + '?f=' + directory files = {'file': open(filePath, 'rb')} s = requests.session() s.post(url, files=files) s.keep_alive = False
def __getReferenceVersion(self,version_id): api = conf.read_config(conf.path, 'API', 'getReferenceVersionApi') url = base + api + '?version_id=' + version_id s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['ATTACHMENTID'] else: return ""
def __getVersion(self,vname,pid): api = conf.read_config(conf.path, 'API', 'getVersionByNameApi') url = base + api + '?versionName=' + vname + '&project_id=' + pid s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['VERSION'] else: return ""
def __getProject(self,uid): api = conf.read_config(conf.path, 'API', 'getProjectApi') url = base + api + '?user_id=' + uid s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['PROJECT'] else: return ""
def __getSingleTask(self,uid,taskId,stepId): api = conf.read_config(conf.path, 'API', 'getSingleTaskApi') url = (base + api + '?uid=' + uid + '&task_id=' + taskId + '&step_id=' + stepId) s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['TASK'] else: return ""
def __getAsset(self,uid,project_id,start,length): api = conf.read_config(conf.path, 'API', 'getAssetApi') url = base + api + '?uid=' + uid + '&project_id=' + project_id + '&start=' + start + '&length=' + length s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['ASSET'] else: return ""
def __getAssetType(self): api = conf.read_config(conf.path, 'API', 'getAssetTypeAPi') url = base + api s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['ASSETTYPE'] else: return ""
def __getSingleAsset(self,pid,entityId,entityType): api = conf.read_config(conf.path, 'API', 'getSingleAssetApi') url = base + api + '?project_id=' + pid + '&entity_id=' + entityId + '&entity_type=' + entityType s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['SA'] else: return ""
def __getImg(self,imgId): api = conf.read_config(conf.path, 'API', 'getImgApi') url = base + api + '?image_id=' + imgId s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['THUMBNAIL'] else: return ""
def __lastVersion(self,vid): api = conf.read_config(conf.path, 'API', 'checkVersionApi2') url = base + api s = requests.session() data = {'id':vid} result = s.post(url,data = data) s.keep_alive = False if result.text != u"null": return result.json()['LASTVERSION'] else: return ""
def __getSequences(self,pid): api = conf.read_config(conf.path, 'API', 'sequencesApi') url = base + api + pid s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['SEQUENCENAME'] else: return ""
def __getFile(self,entity_id,entity_type,project_id): api = conf.read_config(conf.path, 'API', 'workfileApi') url = (base + api + '?entity_id=' + entity_id + '&entity_type=' + entity_type + '&project_id=' + project_id) s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['VERSION'] else: return ""
def __getTask(self,entity_id,entity_type,uid,pid): api = conf.read_config(conf.path, 'API', 'getTaskApi') url = (base + api + '?entity_id=' + entity_id + '&entity_type='+ entity_type + '&uid='+ uid + '&project_id=' + pid ) s = requests.Session() result = requests.post(url) s.keep_alive = False if result.text != u"null": return result.json()['TASKS'] else: return ""
# -*- coding: utf-8 -*- import lib.requests as requests import conf.config as conf base = conf.read_config(conf.path, 'API', 'baseUrl') class Project(object): def __getProject(self,uid): api = conf.read_config(conf.path, 'API', 'getProjectApi') url = base + api + '?user_id=' + uid s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['PROJECT'] else: return "" def callService(self,uid): return self.__getProject(uid) class SingleProject(object): def __getSingleProject(self,pid): api = conf.read_config(conf.path, 'API', 'getSingleProjectApi') url = base + api + '?project_id=' + pid s = requests.session() result = s.post(url) s.keep_alive = False if result.text != u"null": return result.json()['PROJECT'] else: