示例#1
0
def cleanup(mountpoint, tc_mountpoint, tempdir, value_from_argparser):
    try:
        cleanupLogger = ParaLogger('cleanup')
        parser = configtransport()

        #
        # Unmounting Truecrypt
        #
        try:
            if os.path.exists(tc_mountpoint) and os.path.ismount(tc_mountpoint):
                cleanupLogger.info("Unmounting Truecrypt Container")
                cleanupLogger.debug('UNMOUNT COMMAND: ' + parser.get('truecrypting', 'unmount'))
                subprocess.check_call(shlex.split(parser.get('truecrypting', 'unmount')))

        except OSError:
            cleanupLogger.error("Could not unmount tc container on {}").format(tc_mountpoint)
            cleanupLogger.exception("Could not unmount tc container on {}").format(tc_mountpoint)

        #
        # Unmounting USB-Stick
        #

        try:
            if value_from_argparser and os.path.exists(mountpoint) and os.path.ismount(mountpoint) is True:
                cleanupLogger.info("Unmounting USB-Stick")
                if (sys.platform == "darwin"):
                    subprocess.check_call(['diskutil', 'eject', mountpoint])
                else:
                    subprocess.check_call(["umount", mountpoint])
        except OSError:
            cleanupLogger.error("Could not umount {}").format(mountpoint)
            cleanupLogger.exception("Could not umount {}").format(mountpoint)

        #
        # Removing Temporary Directories
        #

        cleanupLogger.info("Cleaning up Temporary Directories")

        try:
            if value_from_argparser and os.path.exists(mountpoint) and os.path.ismount(mountpoint) is False:
                shutil.rmtree(mountpoint)
            if os.path.exists(tc_mountpoint) and os.path.ismount(tc_mountpoint) is False:
                shutil.rmtree(tc_mountpoint)
            if (sys.platform == "darwin") and os.path.exists(tempdir+"/dmg") and os.path.ismount(tempdir+"/dmg"):
                subprocess.check_call(['diskutil', 'eject', os.path.join(tempdir+"/dmg/")])
            elif os.path.exists(tempdir+"/dmg") and os.path.ismount(tempdir+"/dmg"):
                subprocess.check_call(['umount', os.path.join(tempdir+"/dmg/")])
            if os.path.exists(tempdir):
                shutil.rmtree(tempdir)
        except OSError:
            cleanupLogger.error("Some temporary Directories could not be removed")
            cleanupLogger.exception("Some temporary Directories could not be removed")

    except KeyboardInterrupt:
        cleanupLogger.error("You've hit Strg+C for interrupting Parabird. Now clean up your own mess. Exiting...")
        sys.exit()
示例#2
0
def cleanup(mountpoint, tc_mountpoint, tempdir, value_from_argparser):
    try:
        cleanupLogger = ParaLogger("cleanup")
        parser = configtransport()

        #
        # Unmounting Truecrypt
        #
        try:
            if os.path.exists(tc_mountpoint) and os.path.ismount(tc_mountpoint):
                cleanupLogger.info("Unmounting Truecrypt Container")
                cleanupLogger.debug("UNMOUNT COMMAND: " + parser.get("truecrypting", "unmount"))
                subprocess.check_call(shlex.split(parser.get("truecrypting", "unmount")))

        except OSError:
            cleanupLogger.error("Could not unmount tc container on {}").format(tc_mountpoint)
            cleanupLogger.exception("Could not unmount tc container on {}").format(tc_mountpoint)

        #
        # Unmounting USB-Stick
        #

        try:
            if value_from_argparser and os.path.exists(mountpoint) and os.path.ismount(mountpoint) is True:
                cleanupLogger.info("Unmounting USB-Stick")
                if sys.platform == "darwin":
                    subprocess.check_call(["diskutil", "eject", mountpoint])
                else:
                    subprocess.check_call(["umount", mountpoint])
        except OSError:
            cleanupLogger.error("Could not umount {}").format(mountpoint)
            cleanupLogger.exception("Could not umount {}").format(mountpoint)

        #
        # Removing Temporary Directories
        #

        cleanupLogger.info("Cleaning up Temporary Directories")

        try:
            if value_from_argparser and os.path.exists(mountpoint) and os.path.ismount(mountpoint) is False:
                shutil.rmtree(mountpoint)
            if os.path.exists(tc_mountpoint) and os.path.ismount(tc_mountpoint) is False:
                shutil.rmtree(tc_mountpoint)
            if (sys.platform == "darwin") and os.path.exists(tempdir + "/dmg") and os.path.ismount(tempdir + "/dmg"):
                subprocess.check_call(["diskutil", "eject", os.path.join(tempdir + "/dmg/")])
            elif os.path.exists(tempdir + "/dmg") and os.path.ismount(tempdir + "/dmg"):
                subprocess.check_call(["umount", os.path.join(tempdir + "/dmg/")])
            if os.path.exists(tempdir):
                shutil.rmtree(tempdir)
        except OSError:
            cleanupLogger.error("Some temporary Directories could not be removed")
            cleanupLogger.exception("Some temporary Directories could not be removed")

    except KeyboardInterrupt:
        cleanupLogger.error("You've hit Strg+C for interrupting Parabird. Now clean up your own mess. Exiting...")
        sys.exit()
示例#3
0
def cleanup(mountpoint, tc_mountpoint, tempdir):

    mainLogger=ParaLogger('main')
    parser = configtransport()
    clparser = argparse.ArgumentParser()
    clparser = argparse.ArgumentParser(description='')
    clparser.add_argument("-d", "--device", help="Device Flag to specify USB Stick")
    args = clparser.parse_args()

#
# Unmounting Truecrypt
#
    try:
        if os.path.exists(tc_mountpoint) and os.path.ismount(tc_mountpoint):
            mainLogger.info("Unmounting Truecrypt Container")
	    mainLogger.debug('UNMOUNT COMMAND: ' + parser.get('truecrypting', 'unmount'))
	    subprocess.check_call(shlex.split(parser.get('truecrypting', 'unmount')))

    except OSError:
        mainLogger.error("Could not unmount tc container on {}").format(tc_mountpoint)
        mainLogger.exception("Could not unmount tc container on {}").format(tc_mountpoint)
#
# Unmounting USB-Stick
#

    try:
        if args.device and os.path.exists(mountpoint) and os.path.ismount(mountpoint) == True:
            mainLogger.info("Unmounting USB-Stick")
            if (sys.platform == "darwin"):
                subprocess.check_call(['diskutil', 'eject', mountpoint])
            else:
                subprocess.check_call(["umount", mountpoint])
    except OSError:
        mainLogger.error("Could not umount {}").format(mountpoint)
        mainLogger.exception("Could not umount {}").format(mountpoint)

#
# Removing Temporary Directories
#

    mainLogger.info("Cleaning up Temporary Directories")

    try:
        if args.device and os.path.exists(mountpoint) and os.path.ismount(mountpoint) == False:
            shutil.rmtree(mountpoint)
        if os.path.exists(tc_mountpoint) and os.path.ismount(tc_mountpoint) == False:
            shutil.rmtree(tc_mountpoint)
        if (sys.platform == "darwin") and if os.path.exists(tempdir+"/dmg"):
            subprocess.check_call(['diskutil', 'eject', os.path.join(tempdir+"/dmg/")])
        else:
            subprocess.check_call(['umount', os.path.join(tempdir+"/dmg/")])
        if os.path.exists(tempdir):
            shutil.rmtree(tempdir)
    except OSError:
        mainLogger.error("Some temporary Directories could not be removed")
        mainLogger.exception("Some temporary Directories could not be removed")
示例#4
0
            "parabirdy does'nt run on windows. by us a windows license (and some gifts) or reboot in linux. virtualisation might also work"
        )
        sys.exit()

    # Removed, because there is no verbosity support, could be reimplemented later.
    # see the logging module for built in verbosity support
    # if args.verbose:
    #   mainLogger.info("verbosity turned on")

    print "=" * 60, "\nChecking Dependencies and Configure\n", "=" * 60

    print "Tempdir is:", tempdir

    mainLogger.info("Checking all Dependencies...")

    mainLogger.debug("truerypt binary is {}".format(parser.get("truecrypting", "tc_binary")))
    dependency_check([parser.get("truecrypting", "tc_binary"), "--text", "--version"])

    mainLogger.info("Configuring...")

    #
    # Setting Parameters given from argparse
    #

    update_config("DEFAULT", "device", args.device)
    update_config("thunderbird_linux", "version", args.thunder)
    update_config("thunderbird_windows", "version", args.thunder)
    update_config("thunderbird_mac", "version", args.thunder)
    update_config("vidalia_linux", "version", args.vidalia)
    update_config("vidalia_windows", "version", args.vidalia)
    update_config("vidalia_mac", "version", args.vidalia)
示例#5
0
    elif (sys.platform == "win32"):
        mainLogger.error("parabirdy does'nt run on windows. by us a windows license (and some gifts) or reboot in linux. virtualisation might also work")
        sys.exit()

    # Removed, because there is no verbosity support, could be reimplemented later.
    # see the logging module for built in verbosity support
    #if args.verbose:
    #   mainLogger.info("verbosity turned on")

    print "=" * 60, "\nChecking Dependencies and Configure\n", "=" * 60

    print "Tempdir is:", tempdir

    mainLogger.info("Checking all Dependencies...")

    mainLogger.debug("truerypt binary is {}".format(parser.get('truecrypting', 'tc_binary')))
    dependency_check([parser.get('truecrypting', 'tc_binary'), "--text", "--version"])

    mainLogger.info("Configuring...")

    #
    # Setting Parameters given from argparse
    #

    update_config("DEFAULT", "device", args.device)
    update_config("thunderbird_linux", "version", args.thunder)
    update_config("thunderbird_windows", "version", args.thunder)
    update_config("thunderbird_mac", "version", args.thunder)
    update_config("vidalia_linux", "version", args.vidalia)
    update_config("vidalia_windows", "version", args.vidalia)
    update_config("vidalia_mac", "version", args.vidalia)
示例#6
0
    elif (sys.platform == "win32"):
        mainLogger.error("parabirdy does'nt run on windows. by us a windows license (and some gifts) or reboot in linux. virtualisation might also work")
        sys.exit()

    # Removed, because there is no verbosity support, could be reimplemented later.
    # see the logging module for built in verbosity support
    #if args.verbose:
    #   mainLogger.info("verbosity turned on")

    print "=" * 60, "\nChecking Dependencies and Configure\n", "=" * 60

    print "Tempdir is:", tempdir

    mainLogger.info("Checking all Dependencies...")

    mainLogger.debug("truerypt binary is {}".format(parser.get('truecrypting', 'tc_binary')))
    dependency_check([parser.get('truecrypting', 'tc_binary'), "--text", "--version"])
    dependency_check("7z")
    if (sys.platform == "darwin"):
        dependency_check(["hdiutil", "info"])
    else:
        dependency_check("dmg2img")

    mainLogger.info("Configuring...")


    def update_config(section, key, value_from_argparser):
        '''
        This function checks if there is any parameter given,
        If there is a parameter given, it updates the config
        if not it uses default values from config.ini
示例#7
0
            "parabirdy does'nt run on windows. by us a windows license (and some gifts) or reboot in linux. virtualisation might also work"
        )
        sys.exit()

    # Removed, because there is no verbosity support, could be reimplemented later.
    # see the logging module for built in verbosity support
    #if args.verbose:
    #   mainLogger.info("verbosity turned on")

    print "=" * 60, "\nChecking Dependencies and Configure\n", "=" * 60

    print "Tempdir is:", tempdir

    mainLogger.info("Checking all Dependencies...")

    mainLogger.debug("truerypt binary is {}".format(
        parser.get('truecrypting', 'tc_binary')))
    dependency_check(
        [parser.get('truecrypting', 'tc_binary'), "--text", "--version"])

    mainLogger.info("Configuring...")

    #
    # Setting Parameters given from argparse
    #

    update_config("DEFAULT", "device", args.device)
    update_config("thunderbird_linux", "version", args.thunder)
    update_config("thunderbird_windows", "version", args.thunder)
    update_config("thunderbird_mac", "version", args.thunder)
    update_config("vidalia_linux", "version", args.vidalia)
    update_config("vidalia_windows", "version", args.vidalia)