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.')
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.')