code formatting changes
This commit is contained in:
parent
12e4f56d4b
commit
62bc4be0f4
1 changed files with 27 additions and 23 deletions
|
@ -25,8 +25,9 @@ try:
|
||||||
except ImportError: # pragma: nocover
|
except ImportError: # pragma: nocover
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
pwd = os.path.dirname(os.path.abspath(__file__))
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'packages'))
|
sys.path.insert(0, os.path.dirname(pwd))
|
||||||
|
sys.path.insert(0, os.path.join(pwd, 'packages'))
|
||||||
|
|
||||||
from .__about__ import __version__
|
from .__about__ import __version__
|
||||||
from .compat import u, open, is_py3
|
from .compat import u, open, is_py3
|
||||||
|
@ -132,8 +133,10 @@ def parseArguments():
|
||||||
parser.add_argument('--project', dest='project',
|
parser.add_argument('--project', dest='project',
|
||||||
help='optional project name')
|
help='optional project name')
|
||||||
parser.add_argument('--alternate-project', dest='alternate_project',
|
parser.add_argument('--alternate-project', dest='alternate_project',
|
||||||
help='optional alternate project name; auto-discovered project takes priority')
|
help='optional alternate project name; auto-discovered project '+
|
||||||
parser.add_argument('--hostname', dest='hostname', help='hostname of current machine.')
|
'takes priority')
|
||||||
|
parser.add_argument('--hostname', dest='hostname', help='hostname of '+
|
||||||
|
'current machine.')
|
||||||
parser.add_argument('--disableoffline', dest='offline',
|
parser.add_argument('--disableoffline', dest='offline',
|
||||||
action='store_false',
|
action='store_false',
|
||||||
help='disables offline time logging instead of queuing logged time')
|
help='disables offline time logging instead of queuing logged time')
|
||||||
|
@ -290,9 +293,10 @@ def get_user_agent(plugin):
|
||||||
return user_agent
|
return user_agent
|
||||||
|
|
||||||
|
|
||||||
def send_heartbeat(project=None, branch=None, hostname=None, stats={}, key=None, entity=None,
|
def send_heartbeat(project=None, branch=None, hostname=None, stats={}, key=None,
|
||||||
timestamp=None, isWrite=None, plugin=None, offline=None, entity_type='file',
|
entity=None, timestamp=None, isWrite=None, plugin=None,
|
||||||
hidefilenames=None, proxy=None, api_url=None, timeout=None, **kwargs):
|
offline=None, entity_type='file', hidefilenames=None,
|
||||||
|
proxy=None, api_url=None, timeout=None, **kwargs):
|
||||||
"""Sends heartbeat as POST request to WakaTime api server.
|
"""Sends heartbeat as POST request to WakaTime api server.
|
||||||
|
|
||||||
Returns `SUCCESS` when heartbeat was sent, otherwise returns an
|
Returns `SUCCESS` when heartbeat was sent, otherwise returns an
|
||||||
|
@ -376,39 +380,39 @@ def send_heartbeat(project=None, branch=None, hostname=None, stats={}, key=None,
|
||||||
else:
|
else:
|
||||||
log.error(exception_data)
|
log.error(exception_data)
|
||||||
else:
|
else:
|
||||||
response_code = response.status_code if response is not None else None
|
code = response.status_code if response is not None else None
|
||||||
response_content = response.text if response is not None else None
|
content = response.text if response is not None else None
|
||||||
if response_code == requests.codes.created or response_code == requests.codes.accepted:
|
if code == requests.codes.created or code == requests.codes.accepted:
|
||||||
log.debug({
|
log.debug({
|
||||||
'response_code': response_code,
|
'response_code': code,
|
||||||
})
|
})
|
||||||
session_cache.save(session)
|
session_cache.save(session)
|
||||||
return SUCCESS
|
return SUCCESS
|
||||||
if offline:
|
if offline:
|
||||||
if response_code != 400:
|
if code != 400:
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
queue.push(data, json.dumps(stats), plugin)
|
queue.push(data, json.dumps(stats), plugin)
|
||||||
if response_code == 401:
|
if code == 401:
|
||||||
log.error({
|
log.error({
|
||||||
'response_code': response_code,
|
'response_code': code,
|
||||||
'response_content': response_content,
|
'response_content': content,
|
||||||
})
|
})
|
||||||
session_cache.delete()
|
session_cache.delete()
|
||||||
return AUTH_ERROR
|
return AUTH_ERROR
|
||||||
elif log.isEnabledFor(logging.DEBUG):
|
elif log.isEnabledFor(logging.DEBUG):
|
||||||
log.warn({
|
log.warn({
|
||||||
'response_code': response_code,
|
'response_code': code,
|
||||||
'response_content': response_content,
|
'response_content': content,
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
log.error({
|
log.error({
|
||||||
'response_code': response_code,
|
'response_code': code,
|
||||||
'response_content': response_content,
|
'response_content': content,
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
log.error({
|
log.error({
|
||||||
'response_code': response_code,
|
'response_code': code,
|
||||||
'response_content': response_content,
|
'response_content': content,
|
||||||
})
|
})
|
||||||
session_cache.delete()
|
session_cache.delete()
|
||||||
return API_ERROR
|
return API_ERROR
|
||||||
|
|
Loading…
Reference in a new issue