using correct dirname when adding cwd to sys.path in wakatime-cli.py

fixes to wakatime package to allow directly importing.
don't add duplicate handlers to logger in log.py.
This commit is contained in:
Alan Hamlett 2013-08-08 02:09:54 -07:00
parent 08010e86fe
commit 02d54b76f3
3 changed files with 9 additions and 2 deletions

View file

@ -14,7 +14,7 @@ from __future__ import print_function
import os import os
import sys import sys
sys.path.insert(0, os.path.abspath(__file__)) sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import wakatime import wakatime
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -33,6 +33,7 @@ except ImportError:
from urllib.error import HTTPError from urllib.error import HTTPError
from urllib.request import Request, urlopen from urllib.request import Request, urlopen
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from .log import setup_logging from .log import setup_logging
from .project import find_project from .project import find_project
try: try:
@ -52,6 +53,10 @@ class FileAction(argparse.Action):
def parseArguments(argv): def parseArguments(argv):
try:
sys.argv
except AttributeError:
sys.argv = argv
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Wakati.Me event api appender') description='Wakati.Me event api appender')
parser.add_argument('--file', dest='targetFile', metavar='file', parser.add_argument('--file', dest='targetFile', metavar='file',

View file

@ -63,6 +63,9 @@ class JsonFormatter(logging.Formatter):
def setup_logging(args, version): def setup_logging(args, version):
logger = logging.getLogger()
if len(logger.handlers) > 0:
return logger
logfile = args.logfile logfile = args.logfile
if not logfile: if not logfile:
logfile = '~/.wakatime.log' logfile = '~/.wakatime.log'
@ -77,7 +80,6 @@ def setup_logging(args, version):
plugin=args.plugin, plugin=args.plugin,
) )
handler.setFormatter(formatter) handler.setFormatter(formatter)
logger = logging.getLogger()
logger.addHandler(handler) logger.addHandler(handler)
level = logging.INFO level = logging.INFO
if args.verbose: if args.verbose: