コード例 #1
0
def install_cmd(args):
    """
   es_install [basename] [autoload]
   Uses installlib to install an addon by basename
   Alternatively, if no arguments are provided a list of installed addons is displayed
   """
    argc = len(args)
    # Installing an addon
    if argc in (1, 2):
        basename = args[0]
        autoload = (args[1] != '0') if argc == 2 else False

        installer = installlib.getInstaller(basename)
        if installer is None:
            log.write(
                'es_install: Unable find addon on ESAM -- please ensure you have an active internet connection and the basename is valid',
                0)

        else:
            status = installer.install(autoload)
            if status == installer.STATUS_SUCCESSFUL:
                log.write('es_install: %s installed successfully' % basename,
                          0)
            elif status == installer.STATUS_NO_DOWNLOAD:
                log.write(
                    'es_install: Unable to download %s -- please ensure you have an active internet connection'
                    % basename, 0)
            elif status == installer.STATUS_ALREADY_DONE:
                log.write('es_install: %s already installed' % basename, 0)
            elif status == installer.STATUS_NOT_APPROVED:
                log.write('es_install: %s not approved for install' % basename,
                          0)
            else:
                log.write('es_install: Unknown error (%s)' % status, 0)

    # Getting a list of installed addons
    elif not argc:
        addonlist = installlib.infomanager.getInstalled()
        if addonlist:
            maxlength = max(map(len, addonlist))

            es.dbgmsg(
                0, ' %s   Autoloaded\n %s   ----------' %
                ('Basename'.ljust(maxlength), '--------'.ljust(maxlength)))
            for addon in addonlist:
                es.dbgmsg(
                    0, ' %s   %s' %
                    (addon.ljust(maxlength), 'Yes' if installlib.getInstaller(
                        addon, 1).isAutoLoaded() else 'No'))

        else:
            es.dbgmsg(0, 'No installed addons')

    # Invalid usage
    else:
        es.dbgmsg(0, 'Syntax: es_install <basename> [autoload]')
コード例 #2
0
def update_cmd(args):
   """
   es_update <basename> [force update]
   Uses installlib to update an addon by basename
   """
   argc = len(args)
   if argc in (1, 2):
      basename = args[0]
      force    = (args[1] != '0') if argc == 2 else False

      installer = installlib.getInstaller(basename)
      if installer is None:
         log.write('es_install: Unable find addon on ESAM -- please ensure you have an active internet connection and the basename is valid', 0)

      else:
         status = installer.update(force)
         if status == installer.STATUS_SUCCESSFUL:
            log.write('es_update: %s updated successfully' % basename, 0)
         elif status == installer.STATUS_NO_DOWNLOAD:
            log.write('es_update: Unable to download %s -- please ensure you have an active internet connection' % basename, 0)
         elif status == installer.STATUS_NO_INSTALL_INFO:
            log.write('es_update: %s not installed with es_install' % basename, 0)
         elif status == installer.STATUS_ALREADY_DONE:
            log.write('es_update: %s already up to date' % basename, 0)
         elif status == installer.STATUS_NOT_APPROVED:
            log.write('es_update: %s not approved for install' % basename, 0)
         else:
            log.write('es_update: Unknown error (%s)' % status, 0)

   else:
      es.dbgmsg(0, 'Syntax: es_update <basename> [force update]')
コード例 #3
0
def install_cmd(args):
   """
   es_install [basename] [autoload]
   Uses installlib to install an addon by basename
   Alternatively, if no arguments are provided a list of installed addons is displayed
   """
   argc = len(args)
   # Installing an addon
   if argc in (1, 2):
      basename = args[0]
      autoload = (args[1] != '0') if argc == 2 else False

      installer = installlib.getInstaller(basename)
      if installer is None:
         log.write('es_install: Unable find addon on ESAM -- please ensure you have an active internet connection and the basename is valid', 0)

      else:
         status = installer.install(autoload)
         if status == installer.STATUS_SUCCESSFUL:
            log.write('es_install: %s installed successfully' % basename, 0)
         elif status == installer.STATUS_NO_DOWNLOAD:
            log.write('es_install: Unable to download %s -- please ensure you have an active internet connection' % basename, 0)
         elif status == installer.STATUS_ALREADY_DONE:
            log.write('es_install: %s already installed' % basename, 0)
         elif status == installer.STATUS_NOT_APPROVED:
            log.write('es_install: %s not approved for install' % basename, 0)
         else:
            log.write('es_install: Unknown error (%s)' % status, 0)

   # Getting a list of installed addons
   elif not argc:
      addonlist = installlib.infomanager.getInstalled()
      if addonlist:
         maxlength = max(list(map(len, addonlist)))

         es.dbgmsg(0, ' %s   Autoloaded\n %s   ----------' % ('Basename'.ljust(maxlength), '--------'.ljust(maxlength)))
         for addon in addonlist:
            es.dbgmsg(0, ' %s   %s' % (addon.ljust(maxlength), 'Yes' if installlib.getInstaller(addon, 1).isAutoLoaded() else 'No'))

      else:
         es.dbgmsg(0, 'No installed addons')

   # Invalid usage
   else:
      es.dbgmsg(0, 'Syntax: es_install <basename> [autoload]')
コード例 #4
0
def uninstall_cmd(args):
   """
   es_uninstall <basename>
   Uses installlib to uninstall an addon by basename
   """
   if len(args) == 1:
      basename  = args[0]
      installer = installlib.getInstaller(basename, io.StringIO())

      status = installer.uninstall()
      if status == installer.STATUS_SUCCESSFUL:
         log.write('es_uninstall: %s uninstalled successfully' % basename, 0)
      elif status == installer.STATUS_NO_INSTALL_INFO:
         log.write('es_uninstall: %s not installed' % basename, 0)
      else:
         log.write('es_uninstall: Unknown error (%s)' % status, 0)

   else:
      es.dbgmsg(0, 'Syntax: es_uninstall <basename>')