forked from nordprojects/berg-bridge-dump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbridge_command.pyc.py
103 lines (70 loc) · 2.65 KB
/
bridge_command.pyc.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# 2016.01.27 00:42:34 MSK
import time
import byte_tuple
import json
class BridgeCommand(object):
def __init__(self, **kwargs):
self.timestamp = time.time()
self.bridge_address = kwargs.pop('bridge_address', None)
self.command_name = kwargs.pop('command_name', None)
self.command_id = kwargs.pop('command_id', None)
self.params = kwargs.pop('params')
self.completed = False
self._return_code = None
self.url = None
@classmethod
def from_json(cls, cloud_dictionary):
init_params = {}
init_params['bridge_address'] = cloud_dictionary['bridge_address']
init_params['command_id'] = cloud_dictionary['command_id']
json_payload = cloud_dictionary['json_payload']
init_params['command_name'] = json_payload['name']
init_params['params'] = json_payload['params']
instance = cls(**init_params)
return instance
@property
def bridge_address(self):
return self._bridge_address
@bridge_address.setter
def bridge_address(self, value):
if isinstance(value, tuple) or value == None:
self._bridge_address = value
else:
self._bridge_address = byte_tuple.convertToEui64(value)
@property
def bridge_address_hex(self):
if self.bridge_address != None:
return byte_tuple.eui64ToHexString(self.bridge_address, False)
else:
return
def __repr__(self):
return 'BridgeCommand: timestamp %s, bridge_address: %s, command_name: %s, command_id: %s, params: %s' % (self.timestamp,
self.bridge_address_hex,
self.command_name,
self.command_id,
self.params)
@property
def return_code(self):
return self._return_code
@return_code.setter
def return_code(self, value):
if self.completed == False:
self.completed = True
self._return_code = value
def to_json(self):
if not self.completed:
raise RuntimeError, 'to_json() called on non-completed command'
json_hash = {'type': 'BridgeCommandResponse'}
json_hash['timestamp'] = time.time()
json_hash['bridge_address'] = self.bridge_address_hex
json_hash['command_id'] = self.command_id
json_hash['return_code'] = self.return_code
return json.dumps(json_hash)
def param_value_for_key(self, key):
if self.params != None and self.params.has_key(key):
return self.params[key]
else:
return
+++ okay decompyling ./bridge_command.pyc
# decompiled 1 files: 1 okay, 0 failed, 0 verify failed
# 2016.01.27 00:42:34 MSK