예제 #1
0
def olc_files_dirs_check():
    try:

        if not os.path.exists(FILES_PATH):
            os.mkdir(FILES_PATH)
            print "Files folder is missing, lets repopulate."
            print "Created %s/" % FILES_PATH

        if not os.path.exists(HISTORY_FILE_PATH):
            open(HISTORY_FILE_PATH, "a").close()

        dirs = [DOWNLOAD_PATH, EXTRAS_PATH, SCRIPTS_PATH, PROFILES_PATH]

        dprofile = profile()
        for cfg in os.listdir(INTERNAL_PROFILES_PATH):
            if cfg.endswith(".cfg") and not os.path.isdir(cfg) and cfg != "default.cfg":
                try:
                    device_profile = dprofile.load(os.path.join(INTERNAL_PROFILES_PATH, cfg))
                    if device_profile["olfc"]["create_dir"].lower() == "true":
                        dirs.append(os.path.join(FILES_PATH, device_profile["names"]["internal"]))
                except Exception, e:
                    continue

        for item in dirs:
            if not os.path.exists(item):
                if item == SCRIPTS_PATH:
                    copytree(INTERNAL_SCRIPTS_PATH, SCRIPTS_PATH)
                elif item == PROFILES_PATH:
                    copytree(INTERNAL_PROFILES_PATH, PROFILES_PATH)
                else:
                    os.mkdir(item)

                print "Created %s/%s/" % (os.path.basename(os.path.dirname(item)), os.path.basename(item))
            elif not os.path.isdir(item):
                error("Name conflict in files directory.")
예제 #2
0
def olc_files_dirs_check():
    try:

        if not os.path.exists(FILES_PATH):
            os.mkdir(FILES_PATH)
            print 'Files folder is missing, lets repopulate.'
            print 'Created %s/' % FILES_PATH

        if not os.path.exists(HISTORY_FILE_PATH):
            open(HISTORY_FILE_PATH, 'a').close()

        dirs = [DOWNLOAD_PATH, EXTRAS_PATH, SCRIPTS_PATH, PROFILES_PATH]

        dprofile = profile()
        for cfg in os.listdir(INTERNAL_PROFILES_PATH):
            if cfg.endswith('.cfg') and not os.path.isdir(
                    cfg) and cfg != 'default.cfg':
                try:
                    device_profile = dprofile.load(
                        os.path.join(INTERNAL_PROFILES_PATH, cfg))
                    if device_profile['olfc']['create_dir'].lower() == 'true':
                        dirs.append(
                            os.path.join(FILES_PATH,
                                         device_profile['names']['internal']))
                except Exception, e:
                    continue

        for item in dirs:
            if not os.path.exists(item):
                if item == SCRIPTS_PATH:
                    copytree(INTERNAL_SCRIPTS_PATH, SCRIPTS_PATH)
                elif item == PROFILES_PATH:
                    copytree(INTERNAL_PROFILES_PATH, PROFILES_PATH)
                else:
                    os.mkdir(item)

                print 'Created %s/%s/' % (os.path.basename(
                    os.path.dirname(item)), os.path.basename(item))
            elif not os.path.isdir(item):
                error('Name conflict in files directory.')
예제 #3
0
    def __init__(self):
        cmd.Cmd.__init__(self)
        print 'OpenLFConnect Version 1.0.5'
        self.debug = False      
        config.olc_files_dirs_check()
        
        self._init_path = config.FILES_PATH.replace('\\', '/')
        self._lm = loc_manager(self._init_path, cmd.Cmd)
        
        self._dftp_client = None
        self._didj_client = None
        self._pager_client = None
        profile_path_default = os.path.join(config.PROFILES_PATH, 'default.cfg')
        self._profile_path = profile_path_default
        self._profile = profile(profile_path_default)
        self._profile.load(profile_path_default)
        
        self._host_id = ''
        self._device_id = ''
        
        self._lm.set_local(self._lm.local_path)

        readline.set_history_length(50)