version 0.1.3. fixed circular import problem.

This commit is contained in:
Alan Hamlett 2013-07-20 11:55:07 -07:00
parent f659cdaf81
commit 9244c6b0b7
3 changed files with 29 additions and 26 deletions

View file

@ -1,6 +1,6 @@
from setuptools import setup from setuptools import setup
from wakatime.wakatime import __version__ as VERSION from wakatime.__init__ import __version__ as VERSION
packages = [ packages = [
@ -25,7 +25,7 @@ setup(
zip_safe=False, zip_safe=False,
platforms='any', platforms='any',
entry_points={ entry_points={
'console_scripts': ['wakatime = wakatime.wakatime:main'], 'console_scripts': ['wakatime = wakatime.__init__:main'],
}, },
classifiers=( classifiers=(
'Development Status :: 3 - Alpha', 'Development Status :: 3 - Alpha',

18
wakatime-cli.py Normal file
View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
"""
wakatime-cli
~~~~~~~~~~~~
Action event appender for Wakati.Me, auto time tracking for text editors.
:copyright: (c) 2013 Alan Hamlett.
:license: BSD, see LICENSE for more details.
"""
from __future__ import print_function
import sys
import wakatime
if __name__ == '__main__':
sys.exit(wakatime.main(sys.argv))

View file

@ -3,7 +3,7 @@
wakatime wakatime
~~~~~~~~ ~~~~~~~~
Action event appender for Wakati.Me, a time tracking api for text editors. Action event appender for Wakati.Me, auto time tracking for text editors.
:copyright: (c) 2013 Alan Hamlett. :copyright: (c) 2013 Alan Hamlett.
:license: BSD, see LICENSE for more details. :license: BSD, see LICENSE for more details.
@ -12,22 +12,12 @@
from __future__ import print_function from __future__ import print_function
__title__ = 'wakatime' __title__ = 'wakatime'
__version__ = '0.1.2' __version__ = '0.1.3'
__author__ = 'Alan Hamlett' __author__ = 'Alan Hamlett'
__license__ = 'BSD' __license__ = 'BSD'
__copyright__ = 'Copyright 2013 Alan Hamlett' __copyright__ = 'Copyright 2013 Alan Hamlett'
# allow running script directly
if __name__ == '__main__' and __package__ is None:
import os, sys
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parent_dir)
import wakatime
__package__ = 'wakatime'
del os, sys
import base64 import base64
import json import json
import logging import logging
@ -41,11 +31,7 @@ import urllib2
from .log import setup_logging from .log import setup_logging
from .project import find_project from .project import find_project
from .packages import argparse
try:
import argparse
except ImportError:
from .packages import argparse
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -58,7 +44,7 @@ class FileAction(argparse.Action):
setattr(namespace, self.dest, values) setattr(namespace, self.dest, values)
def parseArguments(): def parseArguments(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',
@ -88,7 +74,7 @@ def parseArguments():
parser.add_argument('--verbose', dest='verbose', action='store_true', parser.add_argument('--verbose', dest='verbose', action='store_true',
help='turns on debug messages in log file') help='turns on debug messages in log file')
parser.add_argument('--version', action='version', version=__version__) parser.add_argument('--version', action='version', version=__version__)
args = parser.parse_args() args = parser.parse_args(args=argv[1:])
if not args.timestamp: if not args.timestamp:
args.timestamp = time.time() args.timestamp = time.time()
if not args.key: if not args.key:
@ -178,8 +164,10 @@ def send_action(project=None, tags=None, key=None, targetFile=None,
return False return False
def main(): def main(argv=None):
args = parseArguments() if not argv:
argv = sys.argv
args = parseArguments(argv)
setup_logging(args, __version__) setup_logging(args, __version__)
if os.path.isfile(args.targetFile): if os.path.isfile(args.targetFile):
project = find_project(args.targetFile) project = find_project(args.targetFile)
@ -191,6 +179,3 @@ def main():
log.debug('File does not exist; ignoring this action.') log.debug('File does not exist; ignoring this action.')
return 101 return 101
if __name__ == '__main__':
sys.exit(main())