def processNoUpdate(sid, params): podtag = DBSession.query(model.podtag).get(params['tid']) if not podtag: return dict(errors={'podtag': 'podtag not found'}) #删除对应tag的二进制库 pod = DBSession.query(model.podspec).filter_by(pid=params['pid']).first() try: deleteScript.deleteFramework(copy.deepcopy(pod), podtag.tag, podtag.tagBranch) except Exception, e: status, message = e.args if status == 4: raise APIError(4, message) else: raise APIError(1, traceback.format_exc())
def getJsonModel(podName): pod = DBSession.query( model.podspec).filter_by(podName=unicode(podName)).first() if pod is None: return 0 else: return pod.pid
def process(sid, params): print params['pid'] pod = DBSession.query(model.podspec).get(params['pid']) if not pod: raise APIError(1, 'pod is not existed') #podspecs = DBSession.query(model.podspec).filter_by(pid=55).all() return (pod, 'success.')
def process(sid, params): #删除所有的tag podtags = DBSession.query(model.podtag).filter_by(pid=params['pid']).all() for podtag in podtags: tag_delete.processNoUpdate(sid,{"pid":params['pid'],"tid":podtag.tid}) #删除pod pod = DBSession.query(model.podspec).filter_by(pid=params['pid']).first() if not pod: return dict(errors={'pod':'pod not found'}) DBSession.delete(pod) # 删除成功之后更新未二进制的podspec update_no_lib.process(sid,params) #podspecs = DBSession.query(model.podspec).filter_by(pid=55).all() return ({}, 'success.')
def process(sid, params): #创建对应tag的二进制库 pod = DBSession.query(model.podspec).filter_by(pid=params['pid']).first() try: creatScript.creatFramework(copy.deepcopy(pod), params['tag'], params['tagBranch']) except Exception, e: status, message = e.args if status == 4: raise APIError(4, message) else: raise APIError(1, traceback.format_exc())
def copyNoLibTag(podDir, pid, podName): podtags = DBSession.query(model.podtag).filter_by(pid=pid).all() podtagMap = {} for podtag in podtags: podtagMap[podtag.tag] = 1 for parent, dirnames, filenames in os.walk(podDir): for dirname in dirnames: # 如果tag不存在数据库中则复制过来这个tag的文件夹 if podtagMap.has_key(dirname) == False: if os.path.exists( os.path.join(lib_des_dir + "/" + podName, dirname)): shutil.rmtree( os.path.join(lib_des_dir + "/" + podName, dirname)) shutil.copytree( os.path.join(parent, dirname), os.path.join(lib_des_dir + "/" + podName, dirname)) break
def setUp(self): """Setup test fixture for each model test method.""" try: new_attrs = {} new_attrs.update(self.attrs) new_attrs.update(self.do_get_dependencies()) self.obj = self.klass(**new_attrs) DBSession.add(self.obj) DBSession.flush() return self.obj except: DBSession.rollback() raise
def process(sid, params): podone = DBSession.query(model.podspec).filter_by(podName=params['podName']).first() podtwo = DBSession.query(model.podspec).filter_by(podName=params['repoName']).first() if podone: raise APIError(1,'podName: '+params['podName'] + '已存在') elif podtwo: raise APIError(1,'repoName: '+params['repoName'] + '已存在') newPod = model.podspec(libHttpUrl = params['libHttpUrl'],podspecName = params['podspecName'],sourceHttpUrl = params['sourceHttpUrl'],repoName = params['repoName'],podName = params['podName'],libSSHUrl = params['libSSHUrl'],sourceSSHUrl = params['sourceSSHUrl']) DBSession.add(newPod) DBSession.flush() #podspecs = DBSession.query(model.podspec).filter_by(pid=55).all() return (newPod, 'success.')
def process(sid, params): podspecs = DBSession.query(model.podspec).all() #podspecs = DBSession.query(model.podspec).filter_by(pid=55).all() return (podspecs, 'success.')
def by_user_name(cls, username): """Return the user object whose user name is ``username``.""" return DBSession.query(cls).filter_by(user_name=username).first()
def by_email_address(cls, email): """Return the user object whose email address is ``email``.""" return DBSession.query(cls).filter_by(email_address=email).first()
def test_query_obj(self): """Model objects can be queried""" obj = DBSession.query(self.klass).one() for key, value in self.attrs.items(): eq_(getattr(obj, key), value)
def tearDown(self): """Tear down test fixture for each model test method.""" DBSession.rollback()
return dict(errors={'podtag': 'podtag not found'}) #删除对应tag的二进制库 pod = DBSession.query(model.podspec).filter_by(pid=params['pid']).first() try: deleteScript.deleteFramework(copy.deepcopy(pod), podtag.tag, podtag.tagBranch) except Exception, e: status, message = e.args if status == 4: raise APIError(4, message) else: raise APIError(1, traceback.format_exc()) #删除数据库中的tag信息 DBSession.delete(podtag) # 删除成功之后更新未二进制的podspec update_no_lib.process(sid, params) #podspecs = DBSession.query(model.podspec).filter_by(pid=55).all() return (podtag, 'success.') def processNoUpdate(sid, params): podtag = DBSession.query(model.podtag).get(params['tid']) if not podtag: return dict(errors={'podtag': 'podtag not found'}) #删除对应tag的二进制库 pod = DBSession.query(model.podspec).filter_by(pid=params['pid']).first()
from libcreat.script import creatScript from api_exception import APIError import copy import traceback def process(sid, params): #创建对应tag的二进制库 pod = DBSession.query(model.podspec).filter_by(pid=params['pid']).first() try: creatScript.creatFramework(copy.deepcopy(pod), params['tag'], params['tagBranch']) except Exception, e: status, message = e.args if status == 4: raise APIError(4, message) else: raise APIError(1, traceback.format_exc()) #创建成功则存入数据库 newTag = model.podtag(tagBranch=params['tagBranch'], tag=params['tag'], pid=params['pid']) DBSession.add(newTag) DBSession.flush() #podspecs = DBSession.query(model.podspec).filter_by(pid=55).all() return (newTag, 'success.')