Skip to content

Add a python library for halrun #4230

Description

@hdiethelm

Many python tools use either subprocess.Popen(["halrun", "-Is", "raster.hal"], stdin=subprocess.PIPE) / os.popen("halrun -Is > /dev/null", "w"), os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-f", "touchy.hal"]) or something similar to do hal commands.

All these variants are somewhat non-deterministic. You don't really know when your command will be executed and error handling is not easy.

Some grep'ing:

tests/raster/test:        halrun = subprocess.Popen(["halrun", "-Is", "raster.hal"], stdin=subprocess.PIPE)
src/emc/usr_intf/stepconf/stepconf.py:        self.halrun = halrun = os.popen("halrun -Is", "w")
src/emc/usr_intf/stepconf/stepconf.py:        self.halrun = halrun = os.popen("halrun -Is", "w")
src/emc/usr_intf/pncconf/pncconf.py:            halrun = os.popen("halrun -Is > /dev/null", "w")
src/emc/usr_intf/pncconf/pncconf.py:        halrun = subprocess.Popen("halrun -I", shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE, encoding='utf-8' )
src/emc/usr_intf/pncconf/tests.py:        halrun = os.popen("halrun -Is > /dev/null", "w")
src/emc/usr_intf/pncconf/tests.py:        self.halrun = halrun = os.popen("halrun -Is > /dev/null", "w")
src/emc/usr_intf/pncconf/tests.py:        self.halrun = halrun = os.popen("halrun -Is > /dev/null", "w")
src/emc/usr_intf/pncconf/tests.py:        self.halrun = os.popen("halrun -Is > /dev/null", "w")
src/emc/usr_intf/pncconf/tests.py:            a = os.popen("halrun -U > /dev/null", "w")
src/emc/usr_intf/pncconf/tests.py:            a = os.popen("halrun -U > /dev/null", "w")
...
src/hal/user_comps/gladevcp.py:            
            cmd = ["haltcl", opts.halfile]
        else:
            cmd = ["halcmd", "-f", opts.halfile] 
        res = subprocess.call(cmd, stdout=sys.stdout, stderr=sys.stderr)

src/emc/usr_intf/gscreen/gscreen.py:                res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i", inifile, "-f", f])
src/emc/usr_intf/touchy/touchy.py:            res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-f", "touchy.hal"])
src/emc/usr_intf/touchy/touchy.py:                    res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i", inifile, "-f", f])
src/emc/usr_intf/axis/scripts/axis.py:        cmd = "halcmd loadusr -Wn {0} gladevcp -c {0}".format(gladename).split()
src/emc/usr_intf/axis/scripts/axis.py:                    res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i", vars.emcini.get(), "-f", f])
src/emc/usr_intf/axis/scripts/axis.py:                res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd"] + f.split())
src/emc/usr_intf/mdro/mdro.py:                halcmd_args = ["halcmd", "-V", "-i", args.ini, "-f", f]
src/emc/usr_intf/mdro/mdro.py:                print("halcmd", halcmd_args)
src/emc/usr_intf/mdro/mdro.py:                halcmd_args = ["halcmd", "-i", args.ini, "-f", f]
src/emc/usr_intf/mdro/mdro.py:        res = os.spawnvp(os.P_WAIT, "halcmd", halcmd_args)
src/emc/usr_intf/gmoccapy/gmoccapy.py:                res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i", inifile, "-f", f])
src/emc/usr_intf/gmoccapy/gmoccapy.py:                res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd"] + f.split())
src/emc/usr_intf/qtvcp/qtvcp.py:                cmd = ["halcmd", "-f", opts.halfile]
src/emc/usr_intf/qtvcp/qtvcp.py:                    res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i",self.inipath,"-f", f])
src/emc/usr_intf/qtvcp/qtvcp.py:                res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd"] + f.split())
...

Using something like:

run=hal.halrun()
[ret, out] = run.load(`raster.hal')
[ret, out] = run.cmd('show')
run.exit()

would look much nicer and also be deterministic.

Just an idea for now to park here. Nothing urgent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions