Example #1
0
def paste(location):
	"""paste a file or directory that has been previously copied"""
	copyData = settings.getDataFile()
	if not location:
		location = "."
	try:
		data = pickle.load(open(copyData, "rb"))
		speech.speak("Pasting " + data["copyLocation"] + " to current directory.")
	except:
		speech.fail("It doesn't look like you've copied anything yet.")
		speech.fail("Type 'hallie copy <file>' to copy a file or folder.")
		return
	process, error = subprocess.Popen(["cp", "-r", data["copyLocation"], location], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()
	if "denied" in process:
		speech.fail("Unable to paste your file successfully. This is most likely due to a permission issue. You can try to run me as sudo!")
Example #2
0
def goToDirectory(alias):
	"""go to a saved directory"""
	if not settings.platformCompatible():
		return False
	data = pickle.load(open(settings.getDataFile(), "rb"))
	try:
		data[alias]
	except KeyError:
		speech.fail("Sorry, it doesn't look like you have saved " + alias + " yet.")
		speech.fail("Go to the directory you'd like to save and type 'hallie save as " + alias + "\'")
		return
	try:
		(output, error) = subprocess.Popen(["osascript", "-e", CHANGE_DIR % (data[alias])], stdout=subprocess.PIPE).communicate()
	except:
		speech.fail("Something seems to have gone wrong. Please report this error to [email protected].")
		return
	speech.success("Successfully navigating to " + data[alias])
Example #3
0
def paste(location):
    """paste a file or directory that has been previously copied"""
    copyData = settings.getDataFile()
    if not location:
        location = "."
    try:
        data = pickle.load(open(copyData, "rb"))
        speech.speak("Pasting " + data["copyLocation"] +
                     " to current directory.")
    except:
        speech.fail("It doesn't look like you've copied anything yet.")
        speech.fail("Type 'hallie copy <file>' to copy a file or folder.")
        return
    process, error = subprocess.Popen(
        ["cp", "-r", data["copyLocation"], location],
        stderr=subprocess.STDOUT,
        stdout=subprocess.PIPE).communicate()
    if "denied" in process:
        speech.fail(
            "Unable to paste your file successfully. This is most likely due to a permission issue. You can try to run me as sudo!"
        )
Example #4
0
def goToDirectory(alias):
    """go to a saved directory"""
    if not settings.platformCompatible():
        return False
    data = pickle.load(open(settings.getDataFile(), "rb"))
    try:
        data[alias]
    except KeyError:
        speech.fail("Sorry, it doesn't look like you have saved " + alias +
                    " yet.")
        speech.fail(
            "Go to the directory you'd like to save and type 'hallie save as "
            + alias + "\'")
        return
    try:
        (output, error) = subprocess.Popen(
            ["osascript", "-e", CHANGE_DIR % (data[alias])],
            stdout=subprocess.PIPE).communicate()
    except:
        speech.fail(
            "Something seems to have gone wrong. Please report this error to [email protected]."
        )
        return
    speech.success("Successfully navigating to " + data[alias])