async def delete_local_configuration_routine(self, name: str): """Deletes the local configuration for a container. arg name: The name of the container to de-configure. """ plat = get_local_platform_routines() user = LocalUserRoutines(plat) manager = LocalContainerConfigurationManager(user) cont = self.GetItemByName(name) manager.DeleteByID(cont.GetID())
def validate(self, v: str) -> typing.Tuple[bool, str]: plat = get_local_platform_routines() user = LocalUserRoutines(plat) #check it doesn't already exist local_vols = GetAllRegisteredLocalVolumes(user) for local_vol in local_vols: if local_vol.GetName() == v: return False, v return True, v
def GetUnregisteredRemovableVolumes(localUser:LocalUserRoutines, adjectives = []): """Does platform specific scanning for unregistered removable volumes and returns them. The passed adjectives list is neccesary since removable volumes don't inherently have adjectives. You instead, tell the system what adjectives you want applied to all found volumes when you do the scanning. As removable volumes can migrate from system to system, it's not reasonable to assume the same sets of adjectives mean the same things from system to system. """ ret = [] #useful registry = localvolumeregistry(localUser) platform = get_local_platform_routines() #windows logic for drive letter scanning if isinstance(platform, LocalPlatformWindowsRoutines): #we walk drive letters for mounted drives driveLetters = platform.get_logical_drive_letters() for driveLetter in driveLetters: #check for a volume.name file volumeNamePath = pathlib.Path(os.path.join(driveLetter + ":\\","volume.name")) #UGLY. But empty optical drives throw. And who knows what else. try: if volumeNamePath.exists(): if volumeNamePath.is_file(): with volumeNamePath.open('r') as f: lines = f.readlines() for l in lines: name = l.strip() if len(name) > 0: if name.startswith("#"): #skip comments continue #if we get here, we found a drive with a name #we just need to make sure it's not registered first if len(registry.GetByName(name)) == 0: ret.append(FromParameters(name,driveLetter + ":\\",adjectives)) except: pass return ret
def get_local_volume_choices(adjectives_filter: typing.List[str]): plat = get_local_platform_routines() user = LocalUserRoutines(plat) all_vols = GetAllRegisteredLocalVolumes(user) all_vols.append(GetHomeVolume(user)) choices = {} for vol in all_vols: assert isinstance(vol, localvolume) should_add = False if len(adjectives_filter) == 0: should_add = True else: for adj in adjectives_filter: if vol.HasAdjective(adj): should_add = True if should_add: choices[vol.GetName()] = vol return choices
def _get_fie_pipe_server_client(self, hostname: str, username: str = None): plat = get_local_platform_routines() user = LocalUserRoutines(plat) clnt = fiepipelib.fiepipeserver.client.client(hostname, username, user, False) return clnt
def GetManager(self) -> LocalContainerManager: plat = get_local_platform_routines() user = LocalUserRoutines(plat) return LocalContainerManager(user)
def get_local_user_routines() -> LocalUserRoutines: plat = get_local_platform_routines() user = LocalUserRoutines(plat) return user
def get_storage_mapper(self) -> localstoragemapper: plat = get_local_platform_routines() user = LocalUserRoutines(plat) return localstoragemapper(user)
def GetManager(self) -> GitLabServerManager: return GitLabServerManager( LocalUserRoutines(get_local_platform_routines()))