git://git.onelab.eu
/
unfold.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
translate most modules to using print() as imported from __future__
[unfold.git]
/
activity
/
__init__.py
diff --git
a/activity/__init__.py
b/activity/__init__.py
index
4719a61
..
e8eb5c3
100644
(file)
--- a/
activity/__init__.py
+++ b/
activity/__init__.py
@@
-6,6
+6,8
@@
# The secret is a 64 chars string that is used to sign the request
# The generated signature is a SHA256 hes digest
# The secret is a 64 chars string that is used to sign the request
# The generated signature is a SHA256 hes digest
+from __future__ import print_function
+
import urllib, urllib2
import threading
import hmac
import urllib, urllib2
import threading
import hmac
@@
-37,10
+39,10
@@
else :
def logWrite(request, action, message, objects = None):
if not apikey :
def logWrite(request, action, message, objects = None):
if not apikey :
- print
"===============>> activity: no apikey"
+ print
("===============>> activity: no apikey")
return
if not secret :
return
if not secret :
- print
"===============>> activity: no secret"
+ print
("===============>> activity: no secret")
return
timestamp = time.mktime(datetime.datetime.today().timetuple())
return
timestamp = time.mktime(datetime.datetime.today().timetuple())
@@
-69,12
+71,12
@@
def logWrite(request, action, message, objects = None):
try :
result = urllib2.urlopen(server, urllib.urlencode(log))
try :
result = urllib2.urlopen(server, urllib.urlencode(log))
- print
"===============>> activity: %s <%s> %s" % (action, request.user,message
)
+ print
("===============>> activity: %s <%s> %s" % (action, request.user,message)
)
content = result.read()
except urllib2.URLError as e:
content = result.read()
except urllib2.URLError as e:
- print
"===============>> activity: connection to " + server + " impossible, could not log action"
- print
e.strerror
- print
""
+ print
("===============>> activity: connection to " + server + " impossible, could not log action")
+ print
(e.strerror)
+ print
("")
def log(request, action, message, objects = None):
# Create a new thread in Daemon mode to send the log entry
def log(request, action, message, objects = None):
# Create a new thread in Daemon mode to send the log entry
@@
-93,4
+95,4
@@
def getClientIp(request):
#
# sign the request with the secret key
def sign(secret, message):
#
# sign the request with the secret key
def sign(secret, message):
- return hmac.new(secret, msg=message, digestmod=hashlib.sha256).hexdigest()
\ No newline at end of file
+ return hmac.new(secret, msg=message, digestmod=hashlib.sha256).hexdigest()