diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-11-22 19:13:10 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-11-22 19:13:10 +0000 |
commit | cff6c8bac612ae4ed598ef222ada02d3a83ecaa1 (patch) | |
tree | 4a64951ef30e6795ef2dcebff20c302751885227 /lib/thandy/ClientCLI.py | |
parent | d077d211bbfabeecf0b175df6bfb8e4e96a30747 (diff) |
Add a quick and dirty thandy-client json2xml command. I am going to regret this someday.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17366 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib/thandy/ClientCLI.py')
-rw-r--r-- | lib/thandy/ClientCLI.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/thandy/ClientCLI.py b/lib/thandy/ClientCLI.py index 68be6a1..d6f3adc 100644 --- a/lib/thandy/ClientCLI.py +++ b/lib/thandy/ClientCLI.py @@ -5,6 +5,10 @@ import logging import os import sys import time +try: + import json +except ImportError: + import simplejson as json import thandy.formats import thandy.util @@ -13,6 +17,7 @@ import thandy.download import thandy.master_keys import thandy.packagesys.PackageSystem import thandy.socksurls +import thandy.encodeToXML def update(args): repoRoot = thandy.util.userFilename("cache") @@ -153,14 +158,20 @@ def update(args): logging.info("All downloads finished.") -# Tell me what to install. - +def json2xml(args): + if len(args) != 1: + usage() + f = open(args[0], 'r') + obj = json.load(f) + f.close() + thandy.encodeToXML.encodeToXML(obj, sys.stdout.write) def usage(): print "Known commands:" print " update [--repo=repository] [--no-download] [--loop]" print " [--no-packagesys] [--install] [--socks-port=port]" print " [--debug|--info|--warn] [--force-check]" + print " json2xml file" sys.exit(1) def main(): @@ -169,7 +180,7 @@ def main(): usage() cmd = sys.argv[1] args = sys.argv[2:] - if cmd in [ "update" ]: + if cmd in [ "update", "json2xml" ]: globals()[cmd](args) else: usage() |