@@ -31,12 +31,12 @@ def __init__(
3131 self .used_counts = []
3232
3333 def print_status (self ):
34- print (' -------------------------' )
35- print (' Expiration Date: ' + str (self .expiration_date ))
36- print (' Current count: ' + str (self .count ))
37- print (' PAYG Enabled: ' + str (self .payg_enabled ))
38- print (' Active: ' + str (self .is_active ()))
39- print (' -------------------------' )
34+ print (" -------------------------" )
35+ print (" Expiration Date: " + str (self .expiration_date ))
36+ print (" Current count: " + str (self .count ))
37+ print (" PAYG Enabled: " + str (self .payg_enabled ))
38+ print (" Active: " + str (self .is_active ()))
39+ print (" -------------------------" )
4040
4141 def is_active (self ):
4242 return self .expiration_date > datetime .now ()
@@ -47,24 +47,26 @@ def enter_token(self, token, show_result=True):
4747 return self ._update_device_status_from_token (token_int , show_result )
4848 else :
4949 token_int = int (token )
50- return self ._update_device_status_from_extended_token (token_int , show_result )
50+ return self ._update_device_status_from_extended_token (
51+ token_int , show_result
52+ )
5153
5254 def get_days_remaining (self ):
5355 if self .payg_enabled :
5456 td = self .expiration_date - datetime .now ()
55- days , hours , minutes = td .days , td .seconds // 3600 , (td .seconds // 60 )% 60
56- days = days + (hours + minutes / 60 )/ 24
57+ days , hours , minutes = td .days , td .seconds // 3600 , (td .seconds // 60 ) % 60
58+ days = days + (hours + minutes / 60 ) / 24
5759 return round (days )
5860 else :
59- return ' infinite'
61+ return " infinite"
6062
6163 def _update_device_status_from_token (self , token , show_result = True ):
6264 if (
6365 self .token_entry_blocked_until > datetime .now ()
6466 and self .waiting_period_enabled
6567 ):
6668 if show_result :
67- print (' TOKEN_ENTRY_BLOCKED' )
69+ print (" TOKEN_ENTRY_BLOCKED" )
6870 return False
6971
7072 token_value , token_type , token_count , updated_counts = (
@@ -80,22 +82,22 @@ def _update_device_status_from_token(self, token, show_result=True):
8082 if token_value is None :
8183 if token_type == TokenType .ALREADY_USED :
8284 if show_result :
83- print (' OLD_TOKEN' )
85+ print (" OLD_TOKEN" )
8486 return - 2
8587 if show_result :
86- print (' TOKEN_INVALID' )
88+ print (" TOKEN_INVALID" )
8789 self .invalid_token_count += 1
8890 self .token_entry_blocked_until = datetime .now () + timedelta (
8991 minutes = 2 ** self .invalid_token_count
9092 )
9193 return - 1
9294 elif token_value == - 2 :
9395 if show_result :
94- print (' OLD_TOKEN' )
96+ print (" OLD_TOKEN" )
9597 return - 2
9698 else :
9799 if show_result :
98- print (' TOKEN_VALID' , ' | Value:' , token_value )
100+ print (" TOKEN_VALID" , " | Value:" , token_value )
99101 if (
100102 token_count > self .count
101103 or token_value == OpenPAYGOTokenShared .COUNTER_SYNC_VALUE
@@ -112,7 +114,7 @@ def _update_device_status_from_extended_token(self, token, show_result=True):
112114 and self .waiting_period_enabled
113115 ):
114116 if show_result :
115- print (' TOKEN_ENTRY_BLOCKED' )
117+ print (" TOKEN_ENTRY_BLOCKED" )
116118
117119 token_value , token_count = (
118120 OpenPAYGOTokenDecoder .get_activation_value_count_from_extended_token (
@@ -125,14 +127,14 @@ def _update_device_status_from_extended_token(self, token, show_result=True):
125127 )
126128 if token_value is None :
127129 if show_result :
128- print (' TOKEN_INVALID' )
130+ print (" TOKEN_INVALID" )
129131 self .invalid_token_count += 1
130132 self .token_entry_blocked_until = datetime .now () + timedelta (
131133 minutes = 2 ** self .invalid_token_count
132134 )
133135 else :
134136 if show_result :
135- print (' Special token entered, value: ' + str (token_value ))
137+ print (" Special token entered, value: " + str (token_value ))
136138
137139 def _update_device_status_from_token_value (self , token_value , token_type ):
138140 if token_value <= OpenPAYGOTokenShared .MAX_ACTIVATION_VALUE :
@@ -143,14 +145,15 @@ def _update_device_status_from_token_value(self, token_value, token_type):
143145 elif token_value == OpenPAYGOTokenShared .PAYG_DISABLE_VALUE :
144146 self .payg_enabled = False
145147 elif token_value != OpenPAYGOTokenShared .COUNTER_SYNC_VALUE :
146- # We do nothing if its the sync counter value, the counter has been synced already
147- print ('COUNTER_SYNCED' )
148+ # We do nothing if its the sync counter value, the counter has been synced
149+ # already
150+ print ("COUNTER_SYNCED" )
148151 else :
149152 # If it's another value we also do nothing, as they are not defined
150- print (' UNKNOWN_COMMAND' )
153+ print (" UNKNOWN_COMMAND" )
151154
152155 def _update_expiration_date_from_value (self , toke_value , token_type ):
153- number_of_days = toke_value / self .time_divider
156+ number_of_days = toke_value / self .time_divider
154157 if token_type == TokenType .SET_TIME :
155158 self .expiration_date = datetime .now () + timedelta (days = number_of_days )
156159 else :
0 commit comments