def runSpikesort():

    # deprecated
    # subprocess.call(["klusta", settings.paramsPath])
    subprocess.call(["phy", "spikesort", settings.paramsPath])
    # subprocess.call("klustaviewa")
    subprocess.call(["phy", "cluster-manual", settings.experiment_data_file])
Example #2
1
def get_data_files():
    # generate man pages using rst2man
    try:
        subprocess.call(["rst2man", "nipapd.man.rst", "nipapd.8"])
        subprocess.call(["rst2man", "nipap-passwd.man.rst", "nipap-passwd.1"])
    except OSError as exc:
        print >>sys.stderr, "rst2man failed to run:", str(exc)
        sys.exit(1)

    files = [
        ("/etc/nipap/", ["nipap.conf.dist"]),
        ("/usr/sbin/", ["nipapd", "nipap-passwd"]),
        (
            "/usr/share/nipap/sql/",
            [
                "sql/upgrade-1-2.plsql",
                "sql/upgrade-2-3.plsql",
                "sql/upgrade-3-4.plsql",
                "sql/upgrade-4-5.plsql",
                "sql/functions.plsql",
                "sql/ip_net.plsql",
            ],
        ),
        ("/usr/share/man/man8/", ["nipapd.8"]),
        ("/usr/share/man/man1/", ["nipap-passwd.1"]),
    ]

    return files
Example #3
1
def start_tracing(tracename, args, tracepoints=None):
    buf_size_kb = str(1 * int(args["buf_size_kb"]))
    tp_size = args["tp_size"]

    cmd = "insmod " + kprobe_mod_file
    print(cmd)
    call(cmd, shell=True)
Example #4
1
File: wix.py Project: p1tt1/sumo
def buildMSI(
    sourceZip=INPUT_DEFAULT,
    outFile=OUTPUT_DEFAULT,
    wixBin=WIX_DEFAULT,
    wxs=WXS_DEFAULT,
    license=LICENSE,
    platformSuffix="",
):
    tmpDir = tempfile.mkdtemp()
    zipfile.ZipFile(sourceZip).extractall(tmpDir)
    sumoRoot = glob.glob(os.path.join(tmpDir, "sumo-*"))[0]
    fragments = []
    for d in ["userdoc", "pydoc", "tutorial", "examples"]:
        fragments.append(buildFragment(wixBin, os.path.join(sumoRoot, "docs", d), "DOCDIR", tmpDir))
    fragments.append(buildFragment(wixBin, os.path.join(sumoRoot, "data"), "INSTALLDIR", tmpDir))
    fragments.append(buildFragment(wixBin, os.path.join(sumoRoot, "tools"), "INSTALLDIR", tmpDir))
    wxsIn = open(wxs)
    wxsOut = open(os.path.join(tmpDir, "sumo.wxs"), "w")
    for l in wxsIn:
        l = l.replace("License.rtf", license)
        l = l.replace(".exe' />", "%s.exe' />" % platformSuffix).replace(
            r"Nightly\sumo-gui.exe", r"Nightly\sumo-gui%s.exe" % platformSuffix
        )
        wxsOut.write(l.replace(r"O:\Daten\Sumo\Nightly", os.path.join(sumoRoot, "bin")))
    wxsOut.close()
    wxsIn.close()
    subprocess.call([os.path.join(wixBin, "candle.exe"), "-o", tmpDir + "\\", wxsOut.name] + fragments)
    wixObj = [f.replace(".wxs", ".wixobj") for f in [wxsOut.name] + fragments]
    subprocess.call([os.path.join(wixBin, "light.exe"), "-ext", "WixUIExtension", "-o", outFile] + wixObj)
    shutil.rmtree(tmpDir, True)  # comment this out when debugging
Example #5
1
    def handle(self):
        import os
        import os.path
        import tarfile
        import subprocess

        # check number of arguments
        if self.argumentNum != 1:
            print("usage: boxes unarchive BOX")
            return
            # check arugment's type
        if self.arguments[0]["type"] != "box":
            print("usage: boxes unarchive BOX")
            return
            # check if archive exists
        archivedBoxName = self.arguments[0]["box"]
        if not self.checkArchivedBoxExists(archivedBoxName):
            print("archived box {} doesn't exist".format(archivedBoxName))
            return
            # start to unarchive
            # open tarfile
        boxTarFile = tarfile.open(self.getFullArchivedBoxPath(archivedBoxName), "r:" + self.compressType)
        # unarchive box
        boxTarFile.extractall(self.getFullBoxPath(""))
        # close tarfile
        boxTarFile.close()
        # remove archive file
        os.remove(self.getFullArchivedBoxPath(archivedBoxName))
        # fresh it up
        subprocess.call(["boxes", "fresh", archivedBoxName])
Example #6
1
def installTrove():
    foo = "target" + os.sep + "dependency"
    src_fi = "jcore-mstparser-ae-2.*.jar"
    os.chdir(foo)
    mst = glob.glob(src_fi)[0]

    # extract trove jar from mst repo
    subprocess.call(["jar", "xf", mst, "repo/de/julielab/jules-trove/1.3/jules-trove-1.3.jar"])
    # move trove jar to current dir
    shutil.copy2("repo/de/julielab/jules-trove/1.3/jules-trove-1.3.jar", "./")

    # delete old folder
    shutil.rmtree("repo/")

    # install jules-trove using maven as well?
    subprocess.call(
        [
            "mvn",
            "install:install-file",
            "-Dfile=jules-trove-1.3.jar",
            "-DgroupId=de.julielab",
            "-DartifactId=jules-trove",
            "-Dversion=1.3",
            "-Dpackaging=jar",
        ]
    )
def compile_waxsim():
    previous_dir = os.getcwd()
    os.chdir(os.path.join(os.path.realpath(os.path.split(__file__)[0]), "Contributed", "WaxSim"))
    subprocess.call(
        ["xcodebuild", "-target", "WaxSim", "-configuration", "Release", "SYMROOT=build"], stdout=open("/dev/null", "w")
    )
    os.chdir(previous_dir)
Example #8
1
    def _reboot_buildout(self):
        # rerun bootstrap to recreate bin/buildout with
        # the virtualenf python as the interpreter
        buildout_dir = self.buildout["buildout"]["directory"]
        bootstrap_path = buildout_dir + "/bootstrap.py"
        cmd_list = [self.python_cmd]
        if os.path.exists(bootstrap_path):
            cmd_list.append(bootstrap_path)
            # cmd_list.extend(self.buildout_args)
        else:
            cmd_list.append(self.buildout_path)
            cmd_list.extend(self.buildout_args)
            cmd_list.append("bootstrap")
        subprocess.call(cmd_list)

        # rerun buildout if it isn't running under the
        # virtualenv interpreter
        self.logger.info(sys.executable)
        if sys.executable != self.python_cmd:
            cmd_list = [self.buildout_path]
            cmd_list.extend(self.buildout_args)
            self.logger.info("Rebooting buildout")
            subprocess.call(cmd_list)

            sys.exit()

        pass
Example #9
0
def aria2c_dl(link, filename):
    """Use aria2c as the downloader."""
    command = ["aria2c", "--continue", "--file-allocation=none", "-U", useragent, link, "-o", filename]
    try:
        subprocess.call(command)
    except OSError:
        curl_dl(link, filename)
Example #10
0
def run(Vm, Rm, rates_exc, duration=300, interval=0, configFile="cv.xml"):
    current = [
        [0.5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
        [0.01, 1, -300, 0, 0, 0, 0, 0, 0, 0, 0, 1],
        [0.5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
        [0.6, 1, -100, 0, 0, 0, 0, 0, 0, 0, 0, 1],
        [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
        [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    ]
    preamble = np.sum(current, 0)[0]
    current[-1][0] = duration - preamble
    writeStimFile("current.stim", current)
    conductance = [[preamble, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [duration - preamble, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1]]
    taus = {"exc": 5, "inh": 10}
    for rate in rates_exc:
        for V in Vm:
            ratio = lcg.computeRatesRatio(Vm=V, Rin=Rm)
            Gm_exc, Gm_inh, Gs_exc, Gs_inh = lcg.computeSynapticBackgroundCoefficients(ratio, rate, Rin=Rm)
            print ("Vm = %g, rates = %g Hz (exc) %g Hz (inh)." % (V, rate, rate / ratio))
            conductance[1][2] = Gm_exc
            conductance[1][3] = Gs_exc
            conductance[1][4] = taus["exc"]
            writeStimFile("gexc.stim", conductance)
            conductance[1][2] = Gm_inh
            conductance[1][3] = Gs_inh
            conductance[1][4] = taus["inh"]
            writeStimFile("ginh.stim", conductance)
            sub.call(lcg.common.prog_name + " -V 3 -c " + configFile, shell=True)
            sub.call("sleep " + str(interval), shell=True)
Example #11
0
def ipynb_to_md(ipynb_path):
    os.chdir(os.path.dirname(ipynb_path))
    file_name = os.path.basename(ipynb_path)
    subprocess.call(["python", "-m", "nbconvert", "--to", "markdown", file_name])

    new_s = []
    md_name = file_name.replace(".ipynb", ".md")
    with open(md_name, "r") as f:
        for line in f:
            if line.startswith("#"):
                new_s.append(line)
                break
        for line in f:
            if line.startswith("# API"):
                new_s.append(line)
                new_s.append("\n")
                break
            new_s.append(line)
        for line in f:
            if line.lstrip().startswith("#"):
                break
        for line in f:
            if line.lstrip().startswith("```"):
                continue
            else:
                new_s.append(line[4:])

    with open(md_name, "w") as f:
        f.write("".join(new_s))
Example #12
0
    def run(self):
        # local test

        if wx.Platform == "__WXMSW__":
            try:
                copy(resource_path("") + "7za.exe", getTmpDir())
            except:
                pass
        else:
            try:
                copy("./tools/7za", getTmpDir())
                os.chmod(getTmpDir() + "/7za", 0755)
            except:
                pass

            try:
                copy("../Resources/7za", getTmpDir())
                os.chmod(getTmpDir() + "/7za", 0755)
            except:
                pass

        installQueue = []
        installQueue.append(self.packages["bases"][0]["files"][0]["name"])

        volumes = self.packages["volumes"]
        for item in self.checkItems:
            currentExistsSize = getFolderSize(self.fullPath + "/" + volumes[item]["folder"])
            if currentExistsSize < volumes[item]["size"]:
                for packageFile in volumes[item]["files"]:
                    installQueue.append(packageFile["name"])

        i = 0
        for filename in installQueue:
            extractFile = getDownloadTmpDir() + "/" + filename
            extractPath = self.fullPath

            # if not re.match(r"^base", filename):
            #    extractPath = extractPath + '/' + filename.split('.')[0].split('-')[0]
            #
            #    if not os.path.exists(extractPath):
            #        os.mkdir(extractPath)

            # ./7za x ./Download/base-20120620.7z -o/Volumes/UNTITLED/ -y
            if wx.Platform == "__WXMSW__":
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
                subprocess.call(
                    '%s/7za x %s -o"%s" -y' % (getTmpDir(), extractFile, extractPath), startupinfo=startupinfo
                )
                # os.system("%s/7za x %s -o\"%s\" -y" % (getTmpDir(), extractFile, extractPath))
            else:
                getoutput('%s/7za x %s -o"%s" -y' % (getTmpDir(), extractFile, extractPath))

            i = i + 1

            if self.updateback:
                wx.CallAfter(self.updateback, int(i / float(len(installQueue)) * 100))

        if self.callback:
            wx.CallAfter(self.callback)
Example #13
0
def get_glyph_as_png(fontfile, cp):
    """get a glyph as b64 encoded PNG file"""
    xcp = "%04X" % cp
    fn = "/tmp/U+%s.png" % xcp
    tfn = "/tmp/U+%s.tmp.png" % xcp
    subprocess.call(
        [
            "convert",
            "-background",
            "none",
            "-gravity",
            "center",
            "-size",
            "16x16",
            "-fill",
            "black",
            "-font",
            fontfile,
            "-pointsize",
            "16",
            "label:" + unichr(cp).encode("UTF-8"),
            tfn,
        ]
    )
    subprocess.call(["pngcrush", "-q", "-rem", "alla", tfn, fn])
    os.unlink(tfn)
    with open(fn) as fo:
        result = b64encode(fo.read())
    os.unlink(fn)
    return result
Example #14
0
    def preview(self, fileName):
        """Opens a file using the default application. (Print preview)"""
        if os.name == "posix":
            if sys.platform == "darwin":  # OS X
                self.log.debug("Attempting to preview file {0} via open".format(fileName))
                ret = subprocess.call(["/usr/bin/open", fileName])
                if ret != 0:
                    self.log.error("open returned non-zero exit code {0}".format(ret))
                    return 1
                return 0
            elif sys.platform == "linux2":  # linux
                try:  # attempt to use evince-previewer instead
                    self.log.debug("Attempting to preview file {0} with evince.".format(fileName))
                    ret = subprocess.Popen(("/usr/bin/evince-previewer", fileName))
                    if ret != 0:
                        self.log.error("evince returned non-zero exit code {0}".format(ret))
                        return 1
                    return 0
                except OSError:
                    self.log.debug("evince unavailable.")

                self.log.debug("Attempting to preview file {0} via xdg-open".format(fileName))
                ret = subprocess.call(("/usr/bin/xdg-open", fileName))
                if ret != 0:
                    self.log.error("xdg-open returned non-zero exit code {0}".format(ret))
                    return 1
                return 0
            else:
                self.log.warning("Unable to determine default viewer for POSIX platform {0}".format(sys.platform))
                self.log.warning("Please file a bug and attach a copy of this log.")

        if os.name == "nt":  # UNTESTED
            self.log.debug("Attempting to preview file {0} via win32.startfile".format(fileName))
            os.startfile(filepath)
            return 0
def filter_reports(input_list, dir):
    root_url = "ftp://ftp.sec.gov/"
    for filename in input_list:
        data = read_data((os.path.join(dir, filename)))

        # go line-by-line
        newlines = data.split("\n")
        for line in newlines:

            # filtering magic happens here

            # for 10Q
            if line[:4] == "10-Q":
                columns = line.strip().split(" ")
                # last column will be our url
                # print columns[len(columns) - 1]
                subprocess.call(["touch", dir + "10Q-wget.txt"])
                output = open(dir + "10Q-wget.txt", "a")
                output.write(root_url + columns[len(columns) - 1] + "\n")

            # for 10K
            if line[:3] == "10K":
                columns = line.strip().split(" ")
                # last column will be our url
                # print columns[len(columns) - 1]
                subprocess.call(["touch", dir + "10K-wget.txt"])
                output = open(dir + "10K-wget.txt", "a")
                output.write(root_url + columns[len(columns) - 1] + "\n")
Example #16
0
 def delete(cls, udid):
     """
     Delete the given CoreSimulator device.
     :param udid: The udid of the device.
     :type udid: str
     """
     subprocess.call(["xcrun", "simctl", "delete", udid])
Example #17
0
def runInternal(suffix, args, out=sys.stdout):
    if os.name != "posix":
        suffix += ".exe"
    env = os.environ
    root = os.path.abspath(os.path.dirname(__file__))
    env["TEXTTEST_HOME"] = root
    env["ACTIVITYGEN_BINARY"] = os.path.join(root, "..", "bin", "activitygenInt" + suffix)
    env["DFROUTER_BINARY"] = os.path.join(root, "..", "bin", "dfrouterInt" + suffix)
    env["DUAROUTER_BINARY"] = os.path.join(root, "..", "bin", "duarouterInt" + suffix)
    env["JTRROUTER_BINARY"] = os.path.join(root, "..", "bin", "jtrrouterInt" + suffix)
    env["NETCONVERT_BINARY"] = os.path.join(root, "..", "bin", "netconvertInt" + suffix)
    env["NETGENERATE_BINARY"] = os.path.join(root, "..", "bin", "netgenerateInt" + suffix)
    env["OD2TRIPS_BINARY"] = os.path.join(root, "..", "bin", "od2tripsInt" + suffix)
    env["SUMO_BINARY"] = os.path.join(root, "..", "bin", "meso" + suffix)
    env["POLYCONVERT_BINARY"] = os.path.join(root, "..", "bin", "polyconvertInt" + suffix)
    env["GUISIM_BINARY"] = os.path.join(root, "..", "bin", "meso-gui" + suffix)
    env["MAROUTER_BINARY"] = os.path.join(root, "..", "bin", "marouter" + suffix)
    ttBin = "/usr/bin/texttest"
    if os.name != "posix" or not os.path.exists(ttBin):
        ttBin = "texttest.py"
    subprocess.call(
        "%s %s -a sumo.internal,sumo.meso,complex.meso,duarouter.astar,duarouter.chrouter,netconvert.internal,marouter"
        % (ttBin, args),
        stdout=out,
        stderr=out,
        shell=True,
    )
Example #18
0
    def test_fail(self):
        settings_str = (
            """
[kittyconfig]
auth = tests.gittests.test_utils.AllAuth
[kittygit]
repo_dir = %s 
        """.strip()
            % self.test_dir
        )
        test_settings = fake_settings(settings_str)

        user = "user-%d" % random.randint(0, 100)
        repo_name = "repo-%d" % random.randint(0, 100)
        repo = "%s/%s.git" % (user, repo_name)
        streams = (sys.stdin, sys.stdout, sys.stderr)
        random_root_patterns = random.randint(1, 100)
        request = Request(user, "kitty-git create-repo 'repo'", test_settings, streams, random_root_patterns)
        settings = handlers.get_settings(request)
        full_repo_dir = utils.get_full_repo_dir(settings, user, repo_name)

        self.mox.StubOutWithMock(subprocess, "call")
        subprocess.call(
            args=["git", "--git-dir=.", "init", "--bare"], cwd=full_repo_dir, stdout=sys.stderr, close_fds=True
        ).AndReturn(random.randint(1, 100))

        self.assertRaises(NappingCatException, handlers.create_repo, request, repo_name)
Example #19
0
    def _confirm_commit_msg(self, diff_output):
        """
        Generates a commit message in a temporary file, gives the user a
        chance to edit it, and returns the filename to the caller.
        """

        fd, name = tempfile.mkstemp()
        debug("Storing commit message in temp file: %s" % name)
        os.write(fd, "Update %s to %s\n" % (self.project_name, self.builder.build_version))
        # Write out Resolves line for all bugzillas we see in commit diff:
        for line in extract_bzs(diff_output):
            os.write(fd, line + "\n")

        print ("")
        print ("##### Commit message: #####")
        print ("")

        os.lseek(fd, 0, 0)
        file = os.fdopen(fd)
        for line in file.readlines():
            print line
        file.close()

        print ("")
        print ("###############################")
        print ("")
        answer = raw_input("Would you like to edit this commit message? [y/n] ")
        if answer.lower() in ["y", "yes", "ok", "sure"]:
            debug("Opening editor for user to edit commit message in: %s" % name)
            editor = "vi"
            if "EDITOR" in os.environ:
                editor = os.environ["EDITOR"]
            subprocess.call(editor.split() + [name])

        return name
Example #20
0
 def ana_post_processing(self):
     ana_main_path = self.ana_directory
     ana_post_proc_path = os.path.join(ana_main_path, "ana_postprocessing.py")
     origWD = os.getcwd()  # remember our original working directory
     os.chdir(ana_main_path)
     subprocess.call(["python3", ana_post_proc_path, self.project_directory])
     os.chdir(origWD)
Example #21
0
def sendSlimJob(skim, slim, overwrite, out_dir):
    mc_dir = os.path.dirname(skim)
    skim_name = os.path.basename(skim)
    slim_name = os.path.splitext(os.path.basename(slim))[0]
    if out_dir == None:
        out_dir = os.path.join(mc_dir, "merged_" + slim_name + "_" + skim_name).replace("_skim_", "_")
    else:
        out_dir = os.path.join(out_dir, "merged_" + slim_name + "_" + skim_name).replace("_skim_", "_")
    run_dir = os.path.join(out_dir, "run")
    utilities.ensureDir(run_dir)

    tags = utilities.findBaseSampleNames(skim)
    total_jobs = 0
    for tag in tags:
        # if "TTJets_SingleLeptFromT_" not in tag: continue
        in_files = os.path.join(skim, "*" + tag + "*.root")
        out_name = "mergedbaby_" + tag + "_" + skim_name + "_" + slim_name + "_nfiles_" + str(len(glob.glob(in_files)))
        out_file = os.path.join(out_dir, out_name + ".root")
        run_file = os.path.join(run_dir, out_name + ".sh")

        if os.path.exists(out_file) and not overwrite:
            print("Keeping pre-existing " + out_file)
            continue
        with open(run_file, "wb") as f:
            f.write("#! /bin/bash\n\n")
            # f.write("python/cache.py -c "+slim+" "+out_file+" -e python/slim_ntuple.py "+slim+" "+out_file+" "+in_files+"\n")
            f.write("python/slim_ntuple.py " + slim + " " + out_file + " " + in_files + "\n")
            os.fchmod(f.fileno(), 0755)
        subprocess.call(["JobSubmit.csh", "run/wrapper.sh", run_file])
        total_jobs += 1

    return total_jobs
Example #22
0
    def _SetUserPolicyWin(self, user_policy=None):
        """Writes the given user policy to the Windows registry."""

        def SetValueEx(key, sub_key, value):
            if isinstance(value, int):
                winreg.SetValueEx(key, sub_key, 0, winreg.REG_DWORD, int(value))
            elif isinstance(value, basestring):
                winreg.SetValueEx(key, sub_key, 0, winreg.REG_SZ, value.encode("ascii"))
            elif isinstance(value, list):
                k = winreg.CreateKey(key, sub_key)
                for index, v in list(enumerate(value)):
                    SetValueEx(k, str(index + 1), v)
                winreg.CloseKey(k)
            else:
                raise TypeError('Unsupported data type: "%s"' % value)

        assert self.IsWin()
        if self._branding == "Google Chrome":
            reg_base = r"SOFTWARE\Policies\Google\Chrome"
        else:
            reg_base = r"SOFTWARE\Policies\Chromium"

        if subprocess.call(r"reg query HKEY_LOCAL_MACHINE\%s" % reg_base) == 0:
            logging.debug(r"Removing %s" % reg_base)
            subprocess.call(r"reg delete HKLM\%s /f" % reg_base)

        if user_policy is not None:
            root_key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, reg_base)
            for k, v in user_policy.iteritems():
                SetValueEx(root_key, k, v)
            winreg.CloseKey(root_key)
def start(args, logfile, errfile):

    setup_util.replace_text(
        "gemini/Docroot/WEB-INF/GeminiHello.conf",
        "db.ConnectString = .*:3306",
        "db.ConnectString = " + args.database_host + ":3306",
    )
    setup_util.replace_text(
        "gemini/Docroot/WEB-INF/resin.xml",
        'root-directory=".*\/FrameworkBenchmarks',
        'root-directory="%s' % args.fwroot,
    )

    try:
        subprocess.call("mkdir -p classes", shell=True, cwd="gemini/Docroot/WEB-INF", stderr=errfile, stdout=logfile)
        subprocess.check_call("ant compile", shell=True, cwd="gemini", stderr=errfile, stdout=logfile)
        subprocess.check_call(
            "$RESIN_HOME/bin/resinctl -conf $FWROOT/gemini/Docroot/WEB-INF/resin.xml start",
            shell=True,
            stderr=errfile,
            stdout=logfile,
        )
        return 0
    except subprocess.CalledProcessError:
        return 1
Example #24
0
def compile_dir(dfn):
    """
    Compile *.py in directory `dfn` to *.pyo
    """

    # -OO = strip docstrings
    subprocess.call([PYTHON, "-OO", "-m", "compileall", "-f", dfn])
Example #25
0
def create_catalogFile(voltcompiler, projectFile, catalogFilename):
    catalogFile = "/tmp/" + catalogFilename + ".jar"
    cmd = voltcompiler + " /tmp " + projectFile + " " + catalogFile
    call(cmd, shell=True)
    if not os.path.exists(catalogFile):
        catalogFile = None
    return catalogFile
Example #26
0
    def update_comps(self):
        """
        Update our comps module, so we can pass it to mash to stuff into
        our repositories
        """
        log.debug("Updating comps...")
        comps_dir = config.get("comps_dir")
        comps_url = config.get("comps_url")
        if not exists(comps_dir):
            if comps_url.startswith("git://"):
                cmd = "git clone %s" % (comps_url,)
            else:
                cmd = "cvs -d %s co comps" % (comps_url,)
            log.debug("running command: %s" % cmd)
            subprocess.call(cmd, shell=True, cwd=comps_dir)
        if comps_url.startswith("git://"):
            log.debug("Running git pull")
            p = subprocess.Popen("git pull", shell=True, cwd=comps_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out, err = p.communicate()
            log.debug(out)
            if err:
                log.error(err)
        else:
            subprocess.call("cvs update", shell=True, cwd=comps_dir)

        log.info("Merging translations")
        p = subprocess.Popen("make", shell=True, cwd=comps_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        out, err = p.communicate()
        log.debug(out)
        if err:
            log.error(err)
Example #27
0
def _stop_or_shell(stop, shell, env, ind):
    if _match_cmdnum(stop, ind):
        sys.stdout.write("*** [%d] Waiting for return: " % ind)
        sys.stdin.readline()
    if _match_cmdnum(shell, ind):
        output("*** [%d] Spawning shell\n" % ind, True)
        subprocess.call(os.getenv("SHELL"), env=env)
Example #28
0
def setup_version(requiredVersion):
    """Knowing the required version of The AI Sandbox, check if it's there and
    perform and update if necessary."""

    if not requiredVersion:
        return

    try:
        from aisbx import version

        if version.checkValid(requiredVersion):
            return
        else:
            version.doUpdate()

    except ImportError:
        print >>sys.stderr, "Error initializing The AI Sandbox version %s.  Starting update..." % requiredVersion

        import subprocess

        subprocess.call(
            ["update.exe"], cwd=os.path.join("%LocalAppData%", "AiGameDev.com", "The AI Sandbox"), shell=True
        )
    except:
        print >>sys.stderr, "Fatal error initializing The AI Sandbox version %s!  Please update." % requiredVersion
        import traceback

        print >>sys.stderr, " ".join(traceback.format_exception(*sys.exc_info()))

    sys.exit(-1)
Example #29
0
def gen_grid(options):

    fzmax = options.fzMax
    fgmax = options.fgMax
    coupling = options.coupling
    side = options.side
    dryrun = options.dryrun
    postfix = options.postfix
    print postfix
    fzs = [-fzmax + 2 * fzmax / (side - 1.0) * i for i in range(side)]
    fgs = [-fgmax + 2 * fgmax / (side - 1.0) * i for i in range(side)]
    for fz in fzs:
        for fg in fgs:
            if dryrun:
                subprocess.call(
                    "./gen_zz_atgc_point.sh --dryrun --fz %.4f --fg %.4f --coupling %s --postfix %s"
                    % (fz, fg, coupling, postfix),
                    executable="bash",
                    shell=True,
                )
            else:
                subprocess.call(
                    "./gen_zz_atgc_point.sh  --fz %.4f --fg %.4f --coupling %s --postfix %s"
                    % (fz, fg, coupling, postfix),
                    executable="bash",
                    shell=True,
                )
def freeze(filename, library, make_args=None):
    if make_args is None:
        make_args = []

    name = ".".join(filename.split(".")[:-1])
    library_dir, library_name = os.path.split(os.path.abspath(library))
    library_name = ".".join((library.split("/")[-1][3:]).split(".")[:-1])

    template = make_template
    # generate makefile
    for a, b in (
        ("%name%", name),
        ("%filename%", filename),
        ("%library_dir%", library_dir),
        ("%library_name%", library_name),
        ("%major%", str(major_version)),
    ):
        template = template.replace(a, b)

    with open(filename + ".make", "wb") as make_file:
        make_file.write(bytes(template, "utf8"))

    # call make
    call(["make", "-f", "%s.make" % filename] + make_args)

    # delete makefile
    os.remove(filename + ".make")