Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working development environment #82

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ to your *supervisord.conf*:
```ini
[eventlistener:multivisor-rpc]
command=multivisor-rpc --bind 0:9002
events=PROCESS_STATE,SUPERVISOR_STATE
events=PROCESS_STATE,SUPERVISOR_STATE_CHANGE
```

If no *bind* is given, it defaults to `*:9002`.

You are free to choose the event listener name. As a convention we propose
`multivisor-rpc`.

NB: Make sure that `multivisor-rpc` command is accessible or provide full PATH.

Repeat the above procedure for every supervisor you have running.


Expand Down
2 changes: 2 additions & 0 deletions multivisor/server/rpc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

import sys
import logging
import xmlrpc.client
Expand Down
13 changes: 11 additions & 2 deletions multivisor/server/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def constant_time_compare(val1, val2):

Taken from Django Source Code
"""
val1 = hashlib.sha1(val1).hexdigest()
val1 = hashlib.sha1(_safe_encode(val1)).hexdigest()
if val2.startswith("{SHA}"): # password can be specified as SHA-1 hash in config
val2 = val2.split("{SHA}")[1]
else:
val2 = hashlib.sha1(val2).hexdigest()
val2 = hashlib.sha1(_safe_encode(val2)).hexdigest()
if len(val1) != len(val2):
return False
result = 0
Expand All @@ -40,6 +40,15 @@ def constant_time_compare(val1, val2):
return result == 0


def _safe_encode(data):
"""Safely encode @data string to utf-8"""
try:
result = data.encode("utf-8")
except (UnicodeDecodeError, UnicodeEncodeError, AttributeError):
result = data
return result


def login_required(app):
"""
Decorator to mark view as requiring being logged in
Expand Down
Loading