-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web/core - fixed socket communication for actor status
- Loading branch information
Showing
8 changed files
with
83 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,43 @@ | ||
from inspect import getmembers, ismethod | ||
|
||
from core.config import shared as config | ||
|
||
|
||
class PseudoConfigObject: | ||
pass | ||
|
||
|
||
def _create_pseudo_config(source_obj): | ||
attributes = {} | ||
|
||
for attr in getmembers(source_obj): | ||
if not attr[0].startswith('_'): | ||
value = attr[1] | ||
|
||
if not ismethod(value): | ||
# transform django values to the ones we would expect to get from the db | ||
# could be done in reverse (in the factory) in the future.. would probably be a cleaner way to handle this | ||
if type(value) == bool: | ||
if value: | ||
value = 1 | ||
else: | ||
value = 0 | ||
|
||
attributes[attr[0]] = value | ||
|
||
obj = PseudoConfigObject() | ||
for key, value in attributes.items(): | ||
setattr(obj, key, value) | ||
|
||
return obj | ||
|
||
|
||
def init(agent_obj, server_obj): | ||
try: | ||
_ = config.AGENT.path_root | ||
_ = config.SERVER.security | ||
|
||
except (AttributeError, NameError): | ||
config.init() | ||
config.AGENT = agent_obj | ||
config.SERVER = server_obj | ||
config.AGENT = _create_pseudo_config(agent_obj) | ||
config.SERVER = _create_pseudo_config(server_obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
init_core_config() | ||
from core.sock.connect import Client | ||
from core.config import shared | ||
|
||
|
||
mapping = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters