def release(): build() # changes path!! # copy everything together releasepath = "F2FComputing" try: os.mkdir(releasepath) except OSError: pass try: os.mkdir(join(releasepath,"f2f")) except OSError: pass try: os.mkdir(join(releasepath,"jabberpy")) except OSError: pass srcpath = join("..", "src") headlesssrcpath = join("..","..","F2FHeadless","src") copylist = [ (glob.glob("_f2fcore.*")[0], releasepath), (join("libf2fcore", "f2fcore.py"), releasepath), (join(headlesssrcpath, "f2f", "__init__.py"), join(releasepath,"f2f")), (join(headlesssrcpath, "f2f", "adapter.py"), join(releasepath,"f2f")), (join(headlesssrcpath, "jabberpy", "__init__.py"), join(releasepath,"jabberpy")), (join(headlesssrcpath, "jabberpy", "debug.py"), join(releasepath,"jabberpy")), (join(headlesssrcpath, "jabberpy", "jabber.py"), join(releasepath,"jabberpy")), (join(headlesssrcpath, "jabberpy", "xmlstream.py"), join(releasepath,"jabberpy")), (join(headlesssrcpath, "headlessclient.py"), releasepath), (join(headlesssrcpath, "tests", "montecarlopi.py"), releasepath), (join(headlesssrcpath, "tests", "p2psimple.py"), releasepath), ] for (from_,to) in copylist: print "Copying %s to %s."%(from_, to) shutil.copy(from_, to) print "Packing." killableprocess.call([zippath, "-r", "F2FComputing.zip", "F2FComputing"])
def build(): # make sure the build directory exists try: os.mkdir(builddir) except OSError: pass os.chdir(builddir) killableprocess.call( [sconspath, "-f", join("..", "src", "sconsbuild.py"), "debug=1"])
def release(): build() # changes path!! # copy everything together releasepath = "F2FComputing" try: os.mkdir(releasepath) except OSError: pass try: os.mkdir(join(releasepath, "f2f")) except OSError: pass try: os.mkdir(join(releasepath, "jabberpy")) except OSError: pass srcpath = join("..", "src") headlesssrcpath = join("..", "..", "F2FHeadless", "src") copylist = [ (glob.glob("_f2fcore.*")[0], releasepath), (join("libf2fcore", "f2fcore.py"), releasepath), (join(headlesssrcpath, "f2f", "__init__.py"), join(releasepath, "f2f")), (join(headlesssrcpath, "f2f", "adapter.py"), join(releasepath, "f2f")), (join(headlesssrcpath, "jabberpy", "__init__.py"), join(releasepath, "jabberpy")), (join(headlesssrcpath, "jabberpy", "debug.py"), join(releasepath, "jabberpy")), (join(headlesssrcpath, "jabberpy", "jabber.py"), join(releasepath, "jabberpy")), (join(headlesssrcpath, "jabberpy", "xmlstream.py"), join(releasepath, "jabberpy")), (join(headlesssrcpath, "headlessclient.py"), releasepath), (join(headlesssrcpath, "tests", "montecarlopi.py"), releasepath), (join(headlesssrcpath, "tests", "p2psimple.py"), releasepath), ] for (from_, to) in copylist: print "Copying %s to %s." % (from_, to) shutil.copy(from_, to) print "Packing." killableprocess.call([zippath, "-r", "F2FComputing.zip", "F2FComputing"])
def srcrelease(): # pack all py, i, h, and c files clean() os.chdir("..") srcbuildpath = join("build", "F2FComputingSrc") dirlist = [(x, z) for (x, y, z) in os.walk(".")] os.mkdir(srcbuildpath) for (dirpath, filenames) in dirlist: if not re.search(r"\.svn\b", dirpath): if (dirpath == "."): destpath = join(srcbuildpath, "F2FCore") else: destpath = join(srcbuildpath, "F2FCore", dirpath) print "Creating directory: %s" % destpath os.mkdir(destpath) for file in filenames: if not re.search(r"\.pyc$", file): print "Copying: %s" % file shutil.copy(join(dirpath, file), destpath) os.chdir(join("..", "F2FHeadless")) dirlist = [(x, z) for (x, y, z) in os.walk(".")] srcbuildpath = join("..", "F2FCore", "build", "F2FComputingSrc") for (dirpath, filenames) in dirlist: if not re.search(r"\.svn\b", dirpath): if (dirpath == "."): destpath = join(srcbuildpath, "F2FHeadless") else: destpath = join(srcbuildpath, "F2FHeadless", dirpath) print "Creating directory: %s" % destpath os.mkdir(destpath) for file in filenames: if not re.search(r"\.pyc$", file): print "Copying: %s" % file shutil.copy(join(dirpath, file), destpath) print "Packing." os.chdir(join("..", "F2FCore", "build")) killableprocess.call( [zippath, "-r", "F2FComputingSrc.zip", "F2FComputingSrc"])
def srcrelease(): # pack all py, i, h, and c files clean() os.chdir("..") srcbuildpath = join("build","F2FComputingSrc") dirlist = [(x,z) for (x,y,z) in os.walk(".")] os.mkdir(srcbuildpath) for (dirpath,filenames) in dirlist: if not re.search(r"\.svn\b",dirpath): if(dirpath=="."): destpath = join(srcbuildpath,"F2FCore") else: destpath = join(srcbuildpath,"F2FCore",dirpath) print "Creating directory: %s"%destpath os.mkdir(destpath) for file in filenames: if not re.search(r"\.pyc$",file): print "Copying: %s"%file shutil.copy(join(dirpath,file), destpath) os.chdir(join("..","F2FHeadless")) dirlist = [(x,z) for (x,y,z) in os.walk(".")] srcbuildpath = join("..","F2FCore","build","F2FComputingSrc") for (dirpath,filenames) in dirlist: if not re.search(r"\.svn\b",dirpath): if(dirpath=="."): destpath = join(srcbuildpath,"F2FHeadless") else: destpath = join(srcbuildpath,"F2FHeadless",dirpath) print "Creating directory: %s"%destpath os.mkdir(destpath) for file in filenames: if not re.search(r"\.pyc$",file): print "Copying: %s"%file shutil.copy(join(dirpath,file), destpath) print "Packing." os.chdir(join("..","F2FCore","build")) killableprocess.call([zippath, "-r", "F2FComputingSrc.zip", "F2FComputingSrc"])
def add(self, id, exe, args=[], path=None): if id in self.children.keys(): raise Exception("There is already a child process with that ID.") # Record the arguments used to launch the chld process self.child_args[id] = {"exe": exe, "args": args, "path": path} # Set the correct path if not path: exe_path = exe else: exe_path = path + exe # Merge arguments full_args = [exe_path] + args # Launch process self.children[id] = killableprocess.call( full_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
def train(self, examples, parameters=None, outputDir=None): timeout = -1 if type(examples) == types.StringType: trainFilePath = examples elif type(examples) == types.ListType: examples = self.filterTrainingSet(examples) parameters = copy.copy(parameters) if parameters.has_key("style"): if "no_duplicates" in parameters["style"]: examples = Example.removeDuplicates(examples) del parameters["style"] Example.writeExamples(examples, self.tempDir+"/train.dat") trainFilePath = self.tempDir+"/train.dat" if parameters.has_key("timeout"): timeout = parameters["timeout"] del parameters["timeout"] args = [self.trainBin] if parameters != None: self.__addParametersToSubprocessCall(args, parameters) args += [trainFilePath, self.tempDir+"/model"] return killableprocess.call(args, stdout = self.debugFile, timeout = timeout)
def train(self, examples, parameters=None, outputDir=None): timeout = -1 if type(examples) == types.StringType: trainFilePath = examples elif type(examples) == types.ListType: examples = self.filterTrainingSet(examples) parameters = copy.copy(parameters) if parameters.has_key("style"): if "no_duplicates" in parameters["style"]: examples = Example.removeDuplicates(examples) del parameters["style"] Example.writeExamples(examples, self.tempDir + "/train.dat") trainFilePath = self.tempDir + "/train.dat" if parameters.has_key("timeout"): timeout = parameters["timeout"] del parameters["timeout"] args = [self.trainBin] if parameters != None: self.__addParametersToSubprocessCall(args, parameters) args += [trainFilePath, self.tempDir + "/model"] return killableprocess.call(args, stdout=self.debugFile, timeout=timeout)
def build(): # make sure the build directory exists try: os.mkdir(builddir) except OSError: pass os.chdir(builddir) killableprocess.call([sconspath,"-f", join("..","src","sconsbuild.py"),"debug=1"])