zephyr_mirror: Add support for importing as a library.
(imported from commit 91dc7e8fae89ba8ade8dd98b747a25b46fca13e7)
This commit is contained in:
parent
a728f7936d
commit
ff85226fee
|
@ -16,68 +16,6 @@ root_path = "/mit/tabbott/for_friends"
|
||||||
sys.path[:0] = [root_path, root_path + "/python-zephyr",
|
sys.path[:0] = [root_path, root_path + "/python-zephyr",
|
||||||
root_path + "/python-zephyr/build/lib.linux-x86_64-2.6/"]
|
root_path + "/python-zephyr/build/lib.linux-x86_64-2.6/"]
|
||||||
|
|
||||||
parser = optparse.OptionParser()
|
|
||||||
parser.add_option('--forward-class-messages',
|
|
||||||
dest='forward_class_messages',
|
|
||||||
default=False,
|
|
||||||
help=optparse.SUPPRESS_HELP,
|
|
||||||
action='store_true')
|
|
||||||
parser.add_option('--resend-log',
|
|
||||||
dest='resend_log',
|
|
||||||
default=False,
|
|
||||||
help=optparse.SUPPRESS_HELP,
|
|
||||||
action='store_true')
|
|
||||||
parser.add_option('--enable-log',
|
|
||||||
dest='enable_log',
|
|
||||||
default=False,
|
|
||||||
help=optparse.SUPPRESS_HELP,
|
|
||||||
action='store_true')
|
|
||||||
parser.add_option('--no-forward-personals',
|
|
||||||
dest='forward_personals',
|
|
||||||
help=optparse.SUPPRESS_HELP,
|
|
||||||
default=True,
|
|
||||||
action='store_false')
|
|
||||||
parser.add_option('--forward-from-humbug',
|
|
||||||
dest='forward_from_humbug',
|
|
||||||
default=False,
|
|
||||||
help=optparse.SUPPRESS_HELP,
|
|
||||||
action='store_true')
|
|
||||||
parser.add_option('--verbose',
|
|
||||||
dest='verbose',
|
|
||||||
default=False,
|
|
||||||
help=optparse.SUPPRESS_HELP,
|
|
||||||
action='store_true')
|
|
||||||
parser.add_option('--sync-subscriptions',
|
|
||||||
dest='sync_subscriptions',
|
|
||||||
default=False,
|
|
||||||
action='store_true')
|
|
||||||
parser.add_option('--site',
|
|
||||||
dest='site',
|
|
||||||
default="https://humbughq.com",
|
|
||||||
help=optparse.SUPPRESS_HELP,
|
|
||||||
action='store')
|
|
||||||
parser.add_option('--user',
|
|
||||||
dest='user',
|
|
||||||
default=os.environ["USER"],
|
|
||||||
help=optparse.SUPPRESS_HELP,
|
|
||||||
action='store')
|
|
||||||
parser.add_option('--api-key-file',
|
|
||||||
dest='api_key_file',
|
|
||||||
default=os.path.join(os.environ["HOME"], "Private", ".humbug-api-key"),
|
|
||||||
action='store')
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
api_key = file(options.api_key_file).read().strip()
|
|
||||||
|
|
||||||
import api.common
|
|
||||||
humbug_client = api.common.HumbugAPI(email=options.user + "@mit.edu",
|
|
||||||
api_key=api_key,
|
|
||||||
verbose=True,
|
|
||||||
client="zephyr_mirror",
|
|
||||||
site=options.site)
|
|
||||||
|
|
||||||
start_time = time.time()
|
|
||||||
|
|
||||||
def to_humbug_username(zephyr_username):
|
def to_humbug_username(zephyr_username):
|
||||||
if "@" in zephyr_username:
|
if "@" in zephyr_username:
|
||||||
(user, realm) = zephyr_username.split("@")
|
(user, realm) = zephyr_username.split("@")
|
||||||
|
@ -569,6 +507,69 @@ def parse_zephyr_subs(verbose=False):
|
||||||
zephyr_subscriptions.add((cls.strip(), instance.strip(), recipient.strip()))
|
zephyr_subscriptions.add((cls.strip(), instance.strip(), recipient.strip()))
|
||||||
return zephyr_subscriptions
|
return zephyr_subscriptions
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = optparse.OptionParser()
|
||||||
|
parser.add_option('--forward-class-messages',
|
||||||
|
dest='forward_class_messages',
|
||||||
|
default=False,
|
||||||
|
help=optparse.SUPPRESS_HELP,
|
||||||
|
action='store_true')
|
||||||
|
parser.add_option('--resend-log',
|
||||||
|
dest='resend_log',
|
||||||
|
default=False,
|
||||||
|
help=optparse.SUPPRESS_HELP,
|
||||||
|
action='store_true')
|
||||||
|
parser.add_option('--enable-log',
|
||||||
|
dest='enable_log',
|
||||||
|
default=False,
|
||||||
|
help=optparse.SUPPRESS_HELP,
|
||||||
|
action='store_true')
|
||||||
|
parser.add_option('--no-forward-personals',
|
||||||
|
dest='forward_personals',
|
||||||
|
help=optparse.SUPPRESS_HELP,
|
||||||
|
default=True,
|
||||||
|
action='store_false')
|
||||||
|
parser.add_option('--forward-from-humbug',
|
||||||
|
dest='forward_from_humbug',
|
||||||
|
default=False,
|
||||||
|
help=optparse.SUPPRESS_HELP,
|
||||||
|
action='store_true')
|
||||||
|
parser.add_option('--verbose',
|
||||||
|
dest='verbose',
|
||||||
|
default=False,
|
||||||
|
help=optparse.SUPPRESS_HELP,
|
||||||
|
action='store_true')
|
||||||
|
parser.add_option('--sync-subscriptions',
|
||||||
|
dest='sync_subscriptions',
|
||||||
|
default=False,
|
||||||
|
action='store_true')
|
||||||
|
parser.add_option('--site',
|
||||||
|
dest='site',
|
||||||
|
default="https://humbughq.com",
|
||||||
|
help=optparse.SUPPRESS_HELP,
|
||||||
|
action='store')
|
||||||
|
parser.add_option('--user',
|
||||||
|
dest='user',
|
||||||
|
default=os.environ["USER"],
|
||||||
|
help=optparse.SUPPRESS_HELP,
|
||||||
|
action='store')
|
||||||
|
parser.add_option('--api-key-file',
|
||||||
|
dest='api_key_file',
|
||||||
|
default=os.path.join(os.environ["HOME"], "Private", ".humbug-api-key"),
|
||||||
|
action='store')
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
api_key = file(options.api_key_file).read().strip()
|
||||||
|
|
||||||
|
import api.common
|
||||||
|
humbug_client = api.common.HumbugAPI(email=options.user + "@mit.edu",
|
||||||
|
api_key=api_key,
|
||||||
|
verbose=True,
|
||||||
|
client="zephyr_mirror",
|
||||||
|
site=options.site)
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
if options.sync_subscriptions:
|
if options.sync_subscriptions:
|
||||||
print "Syncing your ~/.zephyr.subs to your Humbug Subscriptions!"
|
print "Syncing your ~/.zephyr.subs to your Humbug Subscriptions!"
|
||||||
add_humbug_subscriptions(True)
|
add_humbug_subscriptions(True)
|
||||||
|
|
Loading…
Reference in a new issue