Пример #1
0
 def add_profile(self, profile):
     """
     Called when a new profile is added remotely (with an updater)
     """
     # where should be stored
     where = os.path.join(self.path, profile.name)
     if not os.path.exists(where):
         touch(where)
     
     profile.path = where
     profile._read_settings()
     profile.write()
Пример #2
0
    def test_append_entry_to_secrets(self):
        pap_path = '/tmp/pap-secrets'
        chap_path = '/tmp/chap-secrets'
        touch(pap_path)
        touch(chap_path)

        append_entry_to_secrets('vodafone', 'vodafone', pap_path, chap_path)
        pap_data = get_file_data(pap_path)
        chap_data = get_file_data(chap_path)

        self.assertEqual(pap_data, '"vodafone"\t*\t"vodafone"\n')
        self.assertEqual(pap_data, chap_data)

        os.unlink(pap_path)
        os.unlink(chap_path)
 def test_append_entry_to_secrets(self):
     pap_path = '/tmp/pap-secrets'
     chap_path = '/tmp/chap-secrets'
     touch(pap_path)
     touch(chap_path)
     
     append_entry_to_secrets('vodafone', 'vodafone', pap_path, chap_path)
     pap_data = get_file_data(pap_path)
     chap_data = get_file_data(chap_path)
     
     self.assertEqual(pap_data, '"vodafone"\t*\t"vodafone"\n')
     self.assertEqual(pap_data, chap_data)
     
     os.unlink(pap_path)
     os.unlink(chap_path)
Пример #4
0
        os.mkdir(consts.MOBILE_PROFILES)
        os.mkdir(consts.DIALER_PROFILES)
        os.mkdir(consts.CACHED_DEVICES)
    except OSError, e:
        pass
    
    # copy plugins to plugins dir
    shutil.copytree(consts.PLUGINS_DIR, consts.PLUGINS_HOME)
    
    from vmc.common.oal import osobj

    join = os.path.join
    cfg_path = join(consts.TEMPLATES_DIR, osobj.abstraction['CFG_TEMPLATE'])
    shutil.copy(cfg_path, consts.VMC_CFG)
    
    touch(consts.CHAP_PROFILE)
    touch(consts.DEFAULT_PROFILE)
    touch(consts.PAP_PROFILE)
    
    os.chmod(consts.VMC_CFG, 0600)
    touch(LOCK)
    
def populate_dbs():
    """
    Populates the different databases
    """
    try:
        # only will succeed on development 
        networks = __import__('resources/extra/networks')
    except ImportError:
        try:
Пример #5
0
        shutil.rmtree(consts.VMC_HOME, True)
        os.mkdir(consts.VMC_HOME)
        os.mkdir(consts.MOBILE_PROFILES)
        os.mkdir(consts.DIALER_PROFILES)
        os.mkdir(consts.CACHED_DEVICES)
    except OSError, e:
        pass

    # copy plugins to plugins dir
    shutil.copytree(consts.PLUGINS_DIR, consts.PLUGINS_HOME)
    print "create skelaton and do setup: finished shutil.copytree"

    # Create the initial config
    ensure_have_config(force_create=True)
    print "create skelaton and do setup: finished ensure_have_config"
    touch(consts.CHAP_PROFILE)
    touch(consts.DEFAULT_PROFILE)
    touch(consts.PAP_PROFILE)
    print "create skelaton and do setup: touch run"
    # This makes not save LOCK file if dialer_profiles have not been correctly created.
    if not os.path.exists(consts.CHAP_PROFILE) or \
            not os.path.exists(consts.DEFAULT_PROFILE) or \
            not os.path.exists(consts.PAP_PROFILE):

        print " Error creating dialer profile."
        message = _(
            'ERROR creating dialer_profile. You should restart the application.'
        )
        dialogs.open_warning_dialog(message, "")
        raise SystemExit()