Implement offline mode in qubes-set-updates tool

This commit is contained in:
Marek Marczykowski-Górecki 2015-08-03 20:28:25 +02:00
parent d27d22a3cf
commit fbfaa98b80
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -20,27 +20,38 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# #
from optparse import OptionParser
import optparse
import os import os
import sys import sys
from qubes.qubes import QubesVmCollection from qubes.qubes import QubesVmCollection
from qubes.qubesutils import updates_vms_toggle,updates_dom0_toggle,\ from qubes.qubesutils import updates_vms_toggle,updates_dom0_toggle,\
updates_dom0_status updates_dom0_status
from qubes.qubes import vmm
def usage():
print "Usage: qubes-set-updates enable|disable|status"
print " Enable or disable globally checking for updates (both dom0 and VM)"
print " Status option checks only dom0 updates status"
def main(): def main():
if len(sys.argv) < 2:
usage()
return 1
action = sys.argv[1] usage = "%prog enable|disable|status\n"\
" Enable or disable globally checking for updates (both dom0 and VM)"\
" Status option checks only dom0 updates status"
parser = OptionParser (usage)
parser.add_option("--offline-mode", dest="offline_mode",
action="store_true", default=False,
help=optparse.SUPPRESS_HELP)
(options, args) = parser.parse_args()
if len(args) < 1:
parser.error("You must provide an action")
action = args[0]
if action not in ['enable', 'disable', 'status']: if action not in ['enable', 'disable', 'status']:
usage() parser.error("Invalid action")
return 1
if options.offline_mode:
vmm.offline_mode = True
qvm_collection = QubesVmCollection() qvm_collection = QubesVmCollection()
if action == 'status': if action == 'status':