Example #1
0
File: jmol.py Project: hpleva/httk
def start(cwd='./', args=['-I']):
    ensure_has_cif2cell()

    version = jmol_version.split('.')
    if len(version) < 3:
        version += [0] * (3 - len(version))
    #if int(version[0]) < 12 or (int(version[0]) == 12 and int(version[1]) < 3):
    if int(version[0]) < 13 or (int(version[0]) == 13 and int(version[1]) == 2
                                and int(version[2]) < 8):
        raise Exception(
            "jmol_ext.start_jmol: requires at least jmol version 13.2.8, your version:"
            + str(jmol_version))

    command = Command(jmol_path, args, cwd=cwd, stophook=_jmol_stophook)
    command.start()

    return command
Example #2
0
def cif2cell(cwd, args, timeout=30):
    ensure_has_cif2cell()

    #raise Exception("Debug: cif2cell call!")
    #p = subprocess.Popen([cif2cell_path]+args, stdout=subprocess.PIPE,
    #                                   stderr=subprocess.PIPE, cwd=cwd)
    #print("COMMAND CIF2CELL",args)
    out, err, completed = Command(cif2cell_path, args, cwd=cwd).run(timeout)
    #print("COMMAND CIF2CELL END",out)
    return out, err, completed
Example #3
0
def platon(cwd, args, timeout=60):
    ensure_has_platon()

    #p = subprocess.Popen([platon_path]+args, stdout=subprocess.PIPE,
    #                                   stderr=subprocess.PIPE, cwd=cwd)
    #out, err = p.communicate()
    #print("COMMAND PLATON")
    #raise Exception("PLATON")
    #print("EXECUTING PLATON",platon_path,args)
    out, err, completed = Command(platon_path, args, cwd=cwd).run(timeout)
    #print("COMMAND PLATON END", out, err, completed, cwd)
    return out, err, completed
Example #4
0
def isotropy(cwd, args, inputstr, timeout=30):
    ensure_has_isotropy()

    #p = subprocess.Popen([cif2cell_path]+args, stdout=subprocess.PIPE,
    #                                   stderr=subprocess.PIPE, cwd=cwd)
    #print("COMMAND CIF2CELL")
    out, err, completed = Command(os.path.join(isotropy_path, 'findsym'),
                                  args,
                                  cwd=cwd,
                                  inputstr=inputstr).run(timeout)
    #print("COMMAND CIF2CELL END")
    return out, err, completed
Example #5
0
def aflow(ioa_in, args, timeout=30):
    ioa_in = httk.IoAdapterString.use(ioa_in)
    #
    #print("COMMAND AFLOW")
    #print("SENDING IN",ioa_in.string)
    out, err, completed = Command(aflow_path, args, inputstr=ioa_in.string).run(timeout)
    #print("COMMAND AFLOW END")
    #return out, err
    #
    #p = subprocess.Popen([aflow_path]+args, stdin=subprocess.PIPE,stdout=subprocess.PIPE,
    #                                   stderr=subprocess.PIPE)
    #out, err = p.communicate(input=ioa_in.string)
    ioa_in.close()
    return out, err, completed
Example #6
0
File: jmol.py Project: hpleva/httk
    def check_works():
        global jmol_version, jmol_version_date

        if jmol_path == "" or not os.path.exists(jmol_path):
            raise ImportError(
                "httk.external.jmol imported without access to a jmol binary. jmol path was set to:"
                + str(jmol_path))

        out, err, completed = Command(jmol_path, ['-n', '-o'],
                                      cwd='./').run(15, debug=False)

        if completed is None or completed != 0:
            raise Exception("jmol_ext: Could not execute jmol. Return code:" +
                            str(completed) + " out:" + str(out) + " err:" +
                            str(err))

        def get_version(results, match):
            results['version'] = match.group(1)
            results['version_date'] = match.group(2)

        # Why do we take os.path.join() of httk.IoAdapterString(out)?
        # Trying to do that in Python 3 fails.
        # results = micro_pyawk(os.path.join(httk.IoAdapterString(out)), [
        # ['^ *Jmol Version: ([^ ]+) +([^ ]+)', None, get_version],
        # ], debug=False)
        results = micro_pyawk(httk.IoAdapterString(out), [
            ['^ *Jmol Version: ([^ ]+) +([^ ]+)', None, get_version],
        ],
                              debug=False)

        if not 'version' in results:
            raise Exception(
                "jmol_ext: Could not extract version string from jmol -n -o. Return code:"
                + str(completed) + " out:" + str(out) + " err:" + str(err))

        jmol_version = results['version']
        jmol_version_date = results['version_date']
Example #7
0
File: jmol.py Project: hpleva/httk
def run(cwd, args, timeout=None):
    ensure_has_cif2cell()
    #print("COMMAND JMOL")
    out, err, completed = Command(jmol_path, args, cwd=cwd).run(timeout)
    #print("COMMMDN JMOL END")
    return out, err, completed