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 wakatime.wakatime import __version__ as VERSION
from wakatime.__init__ import __version__ as VERSION
packages = [
@ -25,7 +25,7 @@ setup(
zip_safe=False,
platforms='any',
entry_points={
'console_scripts': ['wakatime = wakatime.wakatime:main'],
'console_scripts': ['wakatime = wakatime.__init__:main'],
},
classifiers=(
'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
~~~~~~~~
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.
:license: BSD, see LICENSE for more details.
@ -12,22 +12,12 @@
from __future__ import print_function
__title__ = 'wakatime'
__version__ = '0.1.2'
__version__ = '0.1.3'
__author__ = 'Alan Hamlett'
__license__ = 'BSD'
__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 json
import logging
@ -41,10 +31,6 @@ import urllib2
from .log import setup_logging
from .project import find_project
try:
import argparse
except ImportError:
from .packages import argparse
@ -58,7 +44,7 @@ class FileAction(argparse.Action):
setattr(namespace, self.dest, values)
def parseArguments():
def parseArguments(argv):
parser = argparse.ArgumentParser(
description='Wakati.Me event api appender')
parser.add_argument('--file', dest='targetFile', metavar='file',
@ -88,7 +74,7 @@ def parseArguments():
parser.add_argument('--verbose', dest='verbose', action='store_true',
help='turns on debug messages in log file')
parser.add_argument('--version', action='version', version=__version__)
args = parser.parse_args()
args = parser.parse_args(args=argv[1:])
if not args.timestamp:
args.timestamp = time.time()
if not args.key:
@ -178,8 +164,10 @@ def send_action(project=None, tags=None, key=None, targetFile=None,
return False
def main():
args = parseArguments()
def main(argv=None):
if not argv:
argv = sys.argv
args = parseArguments(argv)
setup_logging(args, __version__)
if os.path.isfile(args.targetFile):
project = find_project(args.targetFile)
@ -191,6 +179,3 @@ def main():
log.debug('File does not exist; ignoring this action.')
return 101
if __name__ == '__main__':
sys.exit(main())