コード例 #1
0
ファイル: utils.py プロジェクト: urbas/HomeLib
def restorecon(*paths):
    """
    Restores the SELinux contexts of the given files.

    @param  paths   The files/directories for which to restore their contexts.
    """
    paths = flatten(paths)
    for path in paths:
        runCmd('restorecon', path)
コード例 #2
0
ファイル: utils.py プロジェクト: urbas/HomeLib
def restoreconR(*paths):
    """
    Restores the SELinux contexts of the given files. This method also recurses
    into directories.

    @param  paths   The files/directories for which to restore their contexts.
    """
    paths = flatten(paths)
    for path in paths:
        runCmd('restorecon', '-R', path)
コード例 #3
0
ファイル: config.py プロジェクト: urbas/HomeLib
def updateAllBut(*types):
    """
    This decorator executes the update script if the current machine is not of
    any of the given types. Otherwise it throws the UpdateNotAppliedException
    exception.

    @param  types   A list of machine types to check against.
    """
    types = flatten(types)
    def toUpdate(meth):
        def toUpdateImpl(self):
            if not self.getMain().serviceMyMachines().isMachineOfType(types):
                meth(self)
            else:
                raise UpdateNotAppliedException('Update applicable only for machines not of the following types: ' + ', '.join(types))
        return toUpdateImpl
    return toUpdate
コード例 #4
0
ファイル: config.py プロジェクト: urbas/HomeLib
def updateMachine(*machineNames):
    """
    This decorator executes the update script only for machines with a specific
    name (e.g., 'toncka.urbas.si'). If the current machine's name is not in the
    list then the update will not be applied and a UpdateNotAppliedException
    will be thrown.

    @param  types   A list of machine names (e.g., 'toncka.urbas.si') to check
    against.
    """
    machineNames = flatten(machineNames)
    def toUpdate(meth):
        def toUpdateImpl(self):
            if machineNames and self.getMain().serviceMyMachines().getCurrentMachineName() in machineNames:
                meth(self)
            else:
                raise UpdateNotAppliedException('Update applicable only for the following machines: ' + ', '.join(machineNames))
        return toUpdateImpl
    return toUpdate
コード例 #5
0
ファイル: dialogs.py プロジェクト: urbas/HomeLib
def dlg(title, text, dialogType=DLG_TYPE_info, *args):
    """
    Opens a \c Zenity dialog of the given type with the specified title, text and
    other details.

    @param title   The title of the dialog (displayed in the title-bar of its
                   window).

    @param text    The text to be displayed as the main message of the dialog. This
                   text is located within the dialog.

    @param dialogType  <b>[Optional]</b> The type of dialog to open. Can be one of
                       the following: \ref DLG_TYPE_calendar, \ref DLG_TYPE_entry,
                       \ref DLG_TYPE_error, \ref DLG_TYPE_file_selection,
                       \ref DLG_TYPE_info, \ref DLG_TYPE_list,
                       \ref DLG_TYPE_notification, \ref DLG_TYPE_progress,
                       \ref DLG_TYPE_question, \ref DLG_TYPE_text_info,
                       \ref DLG_TYPE_warning or \ref DLG_TYPE_scale. If not given,
                       'info' will be used.

    @param args    Other arguments to be passed to 'Zenity'. See
                   <b><tt>man zenity</tt></b> for more info.

    @returns    A pair-tuple, where the first element is the return code of the
                finished process and the second element the string contents of
                the application's output.
    """
    (retCode, retMsg) = runCmdGetString(ZENITY, '--' + (dialogType or DLG_TYPE_info), '--title', title, '--text', text, flatten(args))
    if retMsg.endswith('\n'):
        retMsg = retMsg[0:-1]
    return (retCode, retMsg)
コード例 #6
0
ファイル: softwareyum.py プロジェクト: urbas/HomeLib
 def install(self, *packages):
     if packages:
         packages = flatten(packages)
         if runCmd(PACKAGE_MANAGER, "-y", "install", packages):
             raise Exception("Installation process failed.")
         info("Installed packages: " + ", ".join(packages))