def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print("INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists(os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision(opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: print("%s Google V8 code (r%d) from SVN to %s" % ("Update" if update_code else "Checkout", r[-1].number, V8_HOME)) with open(v8_svn_rev_file, 'w') as f: f.write(str(r[-1].number)) return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print("INFO: we will try to use the system 'svn' command to checkout/update V8 code") if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] if exec_cmd(' '.join(args), "checkout or update Google V8 code from SVN"): if not V8_SVN_REVISION: ok, out, err = exec_cmd(' '.join(["svn", "info", V8_HOME]), "save the current V8 SVN revision to REVISION file", output=True) if ok: with open(v8_svn_rev_file, 'w') as f: f.write(re.search(r'Revision:\s(?P<rev>\d+)', out, re.MULTILINE).groupdict()['rev']) else: print("ERROR: fail to fetch SVN info, %s", err)
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print( "INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists( os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision( opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print( "INFO: we will try to use the system 'svn' command to checkout/update V8 code" ) if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] cmdline = ' '.join(args) exec_cmd(cmdline, "checkout or update Google V8 code from SVN")
def checkout_v8(self): update_code = os.path.isdir(V8_HOME) and os.path.exists( os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision( opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: return print "ERROR: Failed to export from V8 svn repository" except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print "INFO: we will try to use the system 'svn' command to checkout/update V8 code" if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] try: proc = subprocess.Popen(args, stdout=sys.stdout, stderr=sys.stderr) proc.communicate() if proc.returncode != 0: print "WARN: fail to checkout or update Google v8 code from SVN, error code: ", proc.returncode except Exception, e: print "ERROR: fail to invoke 'svn' command, please install it first: %s" % e sys.exit(-1)
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print("INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists(os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision(opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: print("%s Google V8 code (r%d) from SVN to %s" % ("Update" if update_code else "Checkout", r[-1].number, V8_HOME)) return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print("INFO: we will try to use the system 'svn' command to checkout/update V8 code") if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] cmdline = ' '.join(args) exec_cmd(cmdline, "checkout or update Google V8 code from SVN")
def checkout_v8(self): update_code = os.path.isdir(V8_HOME) and os.path.exists(os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision(opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: return print "ERROR: Failed to export from V8 svn repository" except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print "INFO: we will try to use the system 'svn' command to checkout/update V8 code" if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] try: proc = subprocess.Popen(args, stdout=sys.stdout, stderr=sys.stderr) proc.communicate() if proc.returncode != 0: print "WARN: fail to checkout or update Google v8 code from SVN, error code: ", proc.returncode except Exception, e: print "ERROR: fail to invoke 'svn' command, please install it first: %s" % e sys.exit(-1)
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print("INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists(os.path.join(V8_HOME, 'include', 'v8.h')) try: print('skipping pysvn install') raise ImportError('Skip attempt to use python-svn/pysvn') from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision(opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: print("%s Google V8 code (r%d) from SVN to %s" % ("Update" if update_code else "Checkout", r[-1].number, V8_HOME)) with open(v8_svn_rev_file, 'w') as f: f.write(str(r[-1].number)) return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print("INFO: we will try to use the system 'svn' command to checkout/update V8 code") # print('PYv8Home %s' % PYV8_HOME) # print('V8_HOME: exiting\n>%s<' % V8_HOME) # import sys # sys.exit(42) if update_code and False: args = ["svn", "up", V8_HOME] # svn: svn up(date) V8_HOME # git: git pull (repository path to update) git_args = ["git", "--work-tree="+V8_HOME,"--git-dir"+V8_HOME+"/.git","pull"] else: os.makedirs(V8_HOME) # make the folder args = ["svn", "co", V8_SVN_URL, V8_HOME] # svn: svn checkout (repo to clone) (location to put it) # git: git clone (repo to clone) (location to put it) git_args = ["git", "clone", V8_GIT_URL, V8_HOME] if V8_SVN_REVISION: # if there is a specific version to pull args += ['-r', str(V8_SVN_REVISION)] # svn: -r specifies the "commit"/branch id/tag whatever to use as version # git: can clone just a specific branch. I'd rather clone it all and checkout # a specific branch, then pull its changes just in case if exec_cmd(' '.join(git_args), "git clone a new repository for Google v8 code"): print('I think it cloned') '''
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print( "INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists( os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision( opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: print("%s Google V8 code (r%d) from SVN to %s" % ("Update" if update_code else "Checkout", r[-1].number, V8_HOME)) with open(v8_svn_rev_file, 'w') as f: f.write(str(r[-1].number)) return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print( "INFO: we will try to use the system 'svn' command to checkout/update V8 code" ) if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] if exec_cmd(' '.join(args), "checkout or update Google V8 code from SVN"): if not V8_SVN_REVISION: ok, out, err = exec_cmd( ' '.join(["svn", "info", V8_HOME]), "save the current V8 SVN revision to REVISION file", output=True) if ok: with open(v8_svn_rev_file, 'w') as f: f.write( re.search(r'Revision:\s(?P<rev>\d+)', out, re.MULTILINE).groupdict()['rev']) else: print("ERROR: fail to fetch SVN info, %s", err)
class Compile(object): def __init__(self, address): self.conn = pymongo.Connection(host=address) self.db = self.conn.ttengine self.svnClient = Client() def update(self, machine, branches): for path in branches: self.svnClient.update(path) # 更新编译 def updateCompile(self, recordId, machine, userId, branches): #self.update(machine, branches) # 先默认是在本机编译 userInfo = self.db.user.find_one({"_id": ObjectId(userId)}) if userInfo is None: data = { "end_time" :datetime.now(), "status" : 2, "remark" : "用户信息为空" } self.updateRecord(recordId, data) return if len(branches) == 0: data = { "end_time" :datetime.now(), "status" : 2, "remark" : "未选择代码分支" } self.updateRecord(recordId, data) return rawDir = os.curdir userName = userInfo["username"] for path in branches: # 运行编译脚本 print "change dir", path os.chdir(path) print "make clean", path p = Popen(["make", "clean", "user=%s" % userName], stdin=PIPE, stdout=PIPE, stderr=PIPE) p.wait() print "make clean completed", path if recordId is not None: print "make -j8 all", path, recordId p = Popen(["make", "-j8", "all", "user=%s" % userName], stdin=PIPE, stdout=PIPE, stderr=PIPE) outStr, errorStr = p.communicate() if len(errorStr) > 0: data = {} data["status"] = 2 data["remark"] = errorStr self.updateRecord(recordId, data) print "compile completed: %s" % path os.chdir(rawDir) data = {} data["end_time"] = datetime.now() data["status"] = 3 data["remark"] = "编译完成" self.updateRecord(recordId, data) def updateRecord(self, recordId, datas): pass #if recordId is not None: # self.db.compiling_record.update({"_id": ObjectId(recordId)}, {"$set": datas}) def getCustomer(self, customerId): customer = self.db.customer.find_one({"_id":ObjectId(customerId)}) return customer def getUser(self, userId): user = self.db.user.find_one({"_id":ObjectId(userId)}) return user
class Compile(object): def __init__(self, address): self.conn = pymongo.Connection(host=address) self.db = self.conn.ttengine self.svnClient = Client() def update(self, machine, branches): for path in branches: self.svnClient.update(path) # 更新编译 def updateCompile(self, recordId, machine, userId, branches): #self.update(machine, branches) # 先默认是在本机编译 userInfo = self.db.user.find_one({"_id": ObjectId(userId)}) if userInfo is None: data = { "end_time": datetime.now(), "status": 2, "remark": "用户信息为空" } self.updateRecord(recordId, data) return if len(branches) == 0: data = { "end_time": datetime.now(), "status": 2, "remark": "未选择代码分支" } self.updateRecord(recordId, data) return rawDir = os.curdir userName = userInfo["username"] for path in branches: # 运行编译脚本 print "change dir", path os.chdir(path) print "make clean", path p = Popen(["make", "clean", "user=%s" % userName], stdin=PIPE, stdout=PIPE, stderr=PIPE) p.wait() print "make clean completed", path if recordId is not None: print "make -j8 all", path, recordId p = Popen(["make", "-j8", "all", "user=%s" % userName], stdin=PIPE, stdout=PIPE, stderr=PIPE) outStr, errorStr = p.communicate() if len(errorStr) > 0: data = {} data["status"] = 2 data["remark"] = errorStr self.updateRecord(recordId, data) print "compile completed: %s" % path os.chdir(rawDir) data = {} data["end_time"] = datetime.now() data["status"] = 3 data["remark"] = "编译完成" self.updateRecord(recordId, data) def updateRecord(self, recordId, datas): pass #if recordId is not None: # self.db.compiling_record.update({"_id": ObjectId(recordId)}, {"$set": datas}) def getCustomer(self, customerId): customer = self.db.customer.find_one({"_id": ObjectId(customerId)}) return customer def getUser(self, userId): user = self.db.user.find_one({"_id": ObjectId(userId)}) return user