Use os.path directly rather than sometimes importing it separately.

(imported from commit 48486c4ea64d02a15faeebb0f490d31e9b113d62)
This commit is contained in:
Tim Abbott 2013-10-28 10:54:32 -04:00
parent 491d21302c
commit 6894453ab5
14 changed files with 38 additions and 40 deletions

View file

@ -4,10 +4,9 @@ import sys
import time import time
import optparse import optparse
from collections import defaultdict from collections import defaultdict
import os
from os import path, environ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(path.join(path.dirname(__file__), '..'))
from zulip_tools import check_output from zulip_tools import check_output
states = { states = {
@ -17,7 +16,7 @@ states = {
3: "UNKNOWN" 3: "UNKNOWN"
} }
if 'USER' in environ and not environ['USER'] in ['root', 'rabbitmq']: if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
print "This script must be run as the root or rabbitmq user" print "This script must be run as the root or rabbitmq user"

View file

@ -3,10 +3,9 @@
import sys import sys
import re import re
import time import time
import os
from os import path, environ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(path.join(path.dirname(__file__), '..'))
from zulip_tools import check_output from zulip_tools import check_output
WARN_THRESHOLD = 50 WARN_THRESHOLD = 50
@ -26,7 +25,7 @@ status = 0
max_count = 0 max_count = 0
warn_queues = [] warn_queues = []
if 'USER' in environ and not environ['USER'] in ['root', 'rabbitmq']: if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
print "This script must be run as the root or rabbitmq user" print "This script must be run as the root or rabbitmq user"
for line in output.split("\n"): for line in output.split("\n"):

View file

@ -6,9 +6,9 @@ import optparse
import urlparse import urlparse
import itertools import itertools
import traceback import traceback
from os import path import os
sys.path.append(path.join(path.dirname(__file__), '../api')) sys.path.append(os.path.join(os.path.dirname(__file__), '../api'))
import zulip import zulip
parser = optparse.OptionParser(r""" parser = optparse.OptionParser(r"""
@ -57,7 +57,7 @@ except ImportError:
def get_calendar_url(): def get_calendar_url():
parts = urlparse.urlparse(options.calendar) parts = urlparse.urlparse(options.calendar)
pat = path.split(parts.path) pat = os.path.split(parts.path)
if pat[1] != 'basic': if pat[1] != 'basic':
parser.error('The --calendar URL should be the XML "Private Address" ' + parser.error('The --calendar URL should be the XML "Private Address" ' +
'from your calendar settings') 'from your calendar settings')

View file

@ -1,13 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
from os import path import os
import logging import logging
import time import time
import simplejson import simplejson
import subprocess import subprocess
import unicodedata import unicodedata
sys.path.append(path.join(path.dirname(__file__), '..', 'api')) sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'api'))
import zulip import zulip
zulip_client = zulip.Client() zulip_client = zulip.Client()

View file

@ -22,7 +22,7 @@
# SOFTWARE. # SOFTWARE.
import sys import sys
from os import path, environ import os
# Configure this script as a Tddium post-build task and it will send # Configure this script as a Tddium post-build task and it will send
@ -42,26 +42,26 @@ from os import path, environ
# Here we assume it's in the parent of the directory # Here we assume it's in the parent of the directory
# where this script lives. # where this script lives.
zulip_directory = path.join(path.dirname(__file__), '../api') zulip_directory = os.path.join(os.path.dirname(__file__), '../api')
sys.path.append(zulip_directory) sys.path.append(zulip_directory)
import zulip import zulip
client = zulip.Client( client = zulip.Client(
email = environ['ZULIP_USER'], email = os.environ['ZULIP_USER'],
api_key = environ.get('ZULIP_API_KEY')) api_key = os.environ.get('ZULIP_API_KEY'))
tddium_server = environ.get('TDDIUM_API_SERVER', 'api.tddium.com') tddium_server = os.environ.get('TDDIUM_API_SERVER', 'api.tddium.com')
report_url = 'https://%s/1/reports/%s' % (tddium_server, environ['TDDIUM_SESSION_ID']) report_url = 'https://%s/1/reports/%s' % (tddium_server, os.environ['TDDIUM_SESSION_ID'])
repo_name = path.basename(environ['TDDIUM_REPO_ROOT']) repo_name = os.path.basename(os.environ['TDDIUM_REPO_ROOT'])
result = client.send_message(dict( result = client.send_message(dict(
type = 'stream', type = 'stream',
to = environ['ZULIP_STREAM'], to = os.environ['ZULIP_STREAM'],
subject = 'build for ' + repo_name, subject = 'build for ' + repo_name,
content = '%s [%s](%s)' % content = '%s [%s](%s)' %
(repo_name, environ['TDDIUM_BUILD_STATUS'], report_url))) (repo_name, os.environ['TDDIUM_BUILD_STATUS'], report_url)))
if result['result'] != 'success': if result['result'] != 'success':
sys.stderr.write('Error sending to Zulip:\n%s\n' % (result['msg'],)) sys.stderr.write('Error sending to Zulip:\n%s\n' % (result['msg'],))

View file

@ -22,7 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
usage = """edit-message [options] --message=<msg_id> --subject=<new subject> --content=<new content> --user=<sender's email address> --api-key=<sender's api key> usage = """edit-message [options] --message=<msg_id> --subject=<new subject> --content=<new content> --user=<sender's email address> --api-key=<sender's api key>
@ -34,7 +34,7 @@ Example: edit-message --message-id="348135" --subject="my subject" --content="te
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
""" """
sys.path.insert(0, path.join(path.dirname(__file__), '..')) sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)

View file

@ -22,7 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
usage = """get-public-streams --user=<bot's email address> --api-key=<bot's api key> [options] usage = """get-public-streams --user=<bot's email address> --api-key=<bot's api key> [options]
@ -34,7 +34,7 @@ Example: get-public-streams --user=othello-bot@example.com --api-key=a0b1c2d3e4f
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
""" """
sys.path.append(path.join(path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)

View file

@ -22,7 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
usage = """list-members --user=<bot's email address> --api-key=<bot's api key> [options] usage = """list-members --user=<bot's email address> --api-key=<bot's api key> [options]
@ -32,7 +32,7 @@ List the names and e-mail addresses of the people in your realm.
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
""" """
sys.path.append(path.join(path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)

View file

@ -22,7 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
usage = """list-subscriptions --user=<bot's email address> --api-key=<bot's api key> [options] usage = """list-subscriptions --user=<bot's email address> --api-key=<bot's api key> [options]
@ -33,7 +33,7 @@ Example: list-subscriptions --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
""" """
sys.path.append(path.join(path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)

View file

@ -22,7 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
usage = """print-messages --user=<bot's email address> --api-key=<bot's api key> [options] usage = """print-messages --user=<bot's email address> --api-key=<bot's api key> [options]
@ -33,7 +33,7 @@ Example: print-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
""" """
sys.path.append(path.join(path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)

View file

@ -22,7 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
usage = """print-next-message --user=<bot's email address> --api-key=<bot's api key> [options] usage = """print-next-message --user=<bot's email address> --api-key=<bot's api key> [options]
@ -33,7 +33,7 @@ Example: print-next-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
""" """
sys.path.append(path.join(path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)

View file

@ -22,9 +22,9 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
sys.path.append(path.join(path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
usage = """send-message --user=<bot's email address> --api-key=<bot's api key> [options] <recipients> usage = """send-message --user=<bot's email address> --api-key=<bot's api key> [options] <recipients>

View file

@ -22,7 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
usage = """subscribe --user=<bot's email address> --api-key=<bot's api key> [options] --streams=<streams> usage = """subscribe --user=<bot's email address> --api-key=<bot's api key> [options] --streams=<streams>
@ -34,7 +34,7 @@ Examples: subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
""" """
sys.path.append(path.join(path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)

View file

@ -22,7 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import sys import sys
from os import path import os
import optparse import optparse
usage = """unsubscribe --user=<bot's email address> --api-key=<bot's api key> [options] --streams=<streams> usage = """unsubscribe --user=<bot's email address> --api-key=<bot's api key> [options] --streams=<streams>
@ -34,7 +34,7 @@ Examples: unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f
You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc
""" """
sys.path.append(path.join(path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import zulip import zulip
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)