no longer allowing entity-type url

This commit is contained in:
Alan Hamlett 2016-04-28 23:57:15 +02:00
parent 6652cda610
commit dc1964cd80
5 changed files with 15 additions and 14 deletions

View file

@ -1,7 +1,7 @@
usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN] usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
[--entitytype ENTITY_TYPE] [--proxy PROXY] [--project PROJECT] [--entity-type ENTITY_TYPE] [--proxy PROXY]
[--alternate-project ALTERNATE_PROJECT] [--project PROJECT] [--alternate-project ALTERNATE_PROJECT]
[--alternate-language ALTERNATE_LANGUAGE] [--alternate-language ALTERNATE_LANGUAGE]
[--hostname HOSTNAME] [--disableoffline] [--hidefilenames] [--hostname HOSTNAME] [--disableoffline] [--hidefilenames]
[--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats] [--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats]

View file

@ -1,7 +1,7 @@
usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN] usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
[--entitytype ENTITY_TYPE] [--proxy PROXY] [--project PROJECT] [--entity-type ENTITY_TYPE] [--proxy PROXY]
[--alternate-project ALTERNATE_PROJECT] [--project PROJECT] [--alternate-project ALTERNATE_PROJECT]
[--alternate-language ALTERNATE_LANGUAGE] [--alternate-language ALTERNATE_LANGUAGE]
[--hostname HOSTNAME] [--disableoffline] [--hidefilenames] [--hostname HOSTNAME] [--disableoffline] [--hidefilenames]
[--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats] [--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats]
@ -25,9 +25,9 @@ optional arguments:
--lineno LINENO optional line number; current line being edited --lineno LINENO optional line number; current line being edited
--cursorpos CURSORPOS --cursorpos CURSORPOS
optional cursor position in the current file optional cursor position in the current file
--entitytype ENTITY_TYPE --entity-type ENTITY_TYPE
entity type for this heartbeat. can be one of "file", entity type for this heartbeat. can be one of "file",
"url", "domain", or "app"; defaults to file. "domain", or "app"; defaults to file.
--proxy PROXY optional https proxy url; for example: --proxy PROXY optional https proxy url; for example:
https://user:pass@localhost:8080 https://user:pass@localhost:8080
--project PROJECT optional project name --project PROJECT optional project name

View file

@ -1,7 +1,7 @@
usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN] usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
[--entitytype ENTITY_TYPE] [--proxy PROXY] [--project PROJECT] [--entity-type ENTITY_TYPE] [--proxy PROXY]
[--alternate-project ALTERNATE_PROJECT] [--project PROJECT] [--alternate-project ALTERNATE_PROJECT]
[--alternate-language ALTERNATE_LANGUAGE] [--alternate-language ALTERNATE_LANGUAGE]
[--hostname HOSTNAME] [--disableoffline] [--hidefilenames] [--hostname HOSTNAME] [--disableoffline] [--hidefilenames]
[--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats] [--exclude EXCLUDE] [--include INCLUDE] [--extra-heartbeats]

View file

@ -419,7 +419,7 @@ class BaseTestCase(utils.TestCase):
config = 'tests/samples/configs/good_config.cfg' config = 'tests/samples/configs/good_config.cfg'
now = u(int(time.time())) now = u(int(time.time()))
args = ['--entity', entity, '--entitytype', 'domain', '--config', config, '--time', now] args = ['--entity', entity, '--entity-type', 'domain', '--config', config, '--time', now]
retval = execute(args) retval = execute(args)
self.assertEquals(retval, API_ERROR) self.assertEquals(retval, API_ERROR)
@ -456,7 +456,7 @@ class BaseTestCase(utils.TestCase):
config = 'tests/samples/configs/good_config.cfg' config = 'tests/samples/configs/good_config.cfg'
now = u(int(time.time())) now = u(int(time.time()))
args = ['--entity', entity, '--entitytype', 'app', '--config', config, '--time', now] args = ['--entity', entity, '--entity-type', 'app', '--config', config, '--time', now]
retval = execute(args) retval = execute(args)
self.assertEquals(retval, API_ERROR) self.assertEquals(retval, API_ERROR)

View file

@ -123,9 +123,9 @@ def parseArguments():
help='optional line number; current line being edited') help='optional line number; current line being edited')
parser.add_argument('--cursorpos', dest='cursorpos', parser.add_argument('--cursorpos', dest='cursorpos',
help='optional cursor position in the current file') help='optional cursor position in the current file')
parser.add_argument('--entitytype', dest='entity_type', parser.add_argument('--entity-type', dest='entity_type',
help='entity type for this heartbeat. can be one of "file", '+ help='entity type for this heartbeat. can be one of "file", '+
'"url", "domain", or "app"; defaults to file.') '"domain", or "app"; defaults to file.')
parser.add_argument('--proxy', dest='proxy', parser.add_argument('--proxy', dest='proxy',
help='optional https proxy url; for example: '+ help='optional https proxy url; for example: '+
'https://user:pass@localhost:8080') 'https://user:pass@localhost:8080')
@ -193,8 +193,6 @@ def parseArguments():
args.key = default_key args.key = default_key
else: else:
parser.error('Missing api key') parser.error('Missing api key')
if not args.entity_type:
args.entity_type = 'file'
if not args.entity: if not args.entity:
if args.file: if args.file:
args.entity = args.file args.entity = args.file
@ -464,6 +462,9 @@ def process_heartbeat(args, configs, hostname, heartbeat):
)) ))
return SUCCESS return SUCCESS
if heartbeat.get('entity_type') not in ['file', 'domain', 'app']:
heartbeat['entity_type'] = 'file'
if heartbeat['entity_type'] != 'file' or os.path.isfile(heartbeat['entity']): if heartbeat['entity_type'] != 'file' or os.path.isfile(heartbeat['entity']):
stats = get_file_stats(heartbeat['entity'], stats = get_file_stats(heartbeat['entity'],