def mount(mountpoint, path=None): """Execute path if mountpoint is mounted. Set path to None to disable.""" label = 'com.github.filipp.machammer.mounthook' defaults.set('/Library/LaunchAgents/%s' % label, 'Label', label) defaults.set('/Library/LaunchAgents/%s' % label, 'Program', path) defaults.set('/Library/LaunchAgents/%s' % label, 'StartOnMount', '-boolean', 'TRUE') defaults.set('/Library/LaunchAgents/%s' % label, 'WatchPaths', '-array', mountpoint)
else: input = os.path.abspath(str(sys.argv[1])) sys.path.append(sys.argv[1]) if os.path.exists('autoshift.setup'): s = open('autoshift.setup','rb') setup = pickle.load(s) s.close() else: s = open(input) sustr= s.read() setup = eval(sustr) defaults.set(setup) expand = series.Series(setup['structure']) #instance of series expansion class if type(setup['param']['scale']) is dict: azero = setup['param']['scale']['azero'] da = setup['param']['scale']['da'] asteps = setup['param']['scale']['steps'] #del setup['param']['scale'] scale = expand.latt_steps(azero, da, asteps) #generate steps in lattice parameter else: scale = setup['param']['scale'] if type(setup['param']['covera']) is dict: coverazero = setup['param']['covera']['coverazero'] dcovera = setup['param']['covera']['dcovera'] coasteps = setup['param']['covera']['steps'] #del setup['param']['covera'] else: covera = setup['param']['covera']
def login(path=None): """Set login hook to path, or disable login hook.""" if path is None: return defaults.delete(PREF_DOMAIN, 'LoginHook') return defaults.set(PREF_DOMAIN, 'LoginHook', path)
def __init__(self): self.currdir = os.getcwd() + "/" if __name__ != "__main__": return if len(sys.argv) <= 1: input = self.currdir + "my_calcsetup.py" else: input = os.path.abspath(str(sys.argv[1])) sys.path.append(sys.argv[1]) if os.path.exists("autoshift.setup"): s = open("autoshift.setup", "r") sustr = s.read() setup = eval(sustr) s.close() else: s = open(input) sustr = s.read() setup = eval(sustr) setup["setupname"] = input defaults.set(setup) if "autoconv" in setup.keys(): is_autoconv = True autoconv = setup.pop("autoconv") s = open(os.getcwd() + "/" + "autoconv.py", "w") s.write(str(autoconv)) s.close() else: is_autoconv = False if "elements" in setup.keys(): path = os.getcwd() elements = setup.pop("elements") initsetup = deepcopy(setup) for element in elements.keys(): proc1 = subprocess.Popen(["cd %s" % path], shell=True) proc1.communicate() del setup["param"]["scale"] setup["param"]["scale"] = initsetup["param"]["scale"] setup["species"] = element name = "%s_" % element for key in elements[element].keys(): name = name + str(elements[element][key]) if key == "azero": setup["param"]["scale"]["azero"] = elements[element]["azero"] else: setup[key] = elements[element][key] if os.path.exists(path + "/" + name): continue proc2 = subprocess.Popen(["mkdir %s" % name], shell=True) proc2.communicate() setup["calchome"] = path + "/" + name + "/" s = open(path + "/" + name + "/" + "setup.py", "w") s.write(str(setup)) s.close() self.setup_element(setup) else: if is_autoconv: print "true" if "rgkmax" in autoconv["start"].keys(): proc2 = subprocess.Popen(["mkdir conv_rgkmax"], shell=True) proc2.communicate() proc3 = subprocess.Popen(["mkdir conv_rgkmax/conv_step_0"], shell=True) proc3.communicate() setup["calchome"] = os.getcwd() + "/conv_rgkmax/conv_step_0/" setup["param"]["rgkmax"] = [ autoconv["start"]["rgkmax"], autoconv["start"]["rgkmax"] + autoconv["stepsize"]["rgkmax"], autoconv["start"]["rgkmax"] + autoconv["stepsize"]["rgkmax"] * 2, ] self.setup_element(setup)