forked from binaryage/firelogger.py
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
29 lines (21 loc) · 725 Bytes
/
utils.py
File metadata and controls
29 lines (21 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- mode: python; coding: utf-8 -*-
import firepython
try:
import simplejson
except ImportError:
from django.utils import simplejson
try:
from hashlib import md5
except ImportError:
from md5 import md5
class TolerantJSONEncoder(simplejson.JSONEncoder):
def default(self, o):
return str(o)
def json_encode(data):
return simplejson.dumps(data, cls=TolerantJSONEncoder)
def get_version_header(version = firepython.__version__):
return (firepython.FIRELOGGER_VERSION_HEADER, version)
def get_auth_token(password):
return md5('#FireLoggerPassword#%s#' % password).hexdigest()
def get_auth_header(password):
return (firepython.FIRELOGGER_AUTH_HEADER, get_auth_token(password))