1818from termcolor import colored , cprint
1919
2020import pyalarmdotcomajax
21- from pyalarmdotcomajax import AlarmController , AuthResult
22- from pyalarmdotcomajax .errors import (
21+
22+ from . import AlarmController , AuthResult
23+ from .devices import DEVICE_URLS , BaseDevice , DeviceType
24+ from .devices .light import Light
25+ from .devices .sensor import Sensor
26+ from .devices .system import System
27+ from .errors import (
2328 AuthenticationFailed ,
2429 DataFetchFailed ,
2530 InvalidConfigurationOption ,
2631 NagScreen ,
2732 UnexpectedDataStructure ,
2833)
29- from pyalarmdotcomajax .extensions import ConfigurationOption
30- from pyalarmdotcomajax .helpers import ExtendedEnumMixin , slug_to_title
31-
32- from .devices import DEVICE_URLS , BaseDevice , DeviceType
33- from .devices .light import Light
34- from .devices .sensor import Sensor
35- from .devices .system import System
34+ from .extensions import ConfigurationOption
35+ from .helpers import ExtendedEnumMixin , slug_to_title
3636
3737CLI_CARD_BREAK = "" # "--------"
3838
@@ -221,10 +221,8 @@ async def cli() -> None:
221221 login_result = await alarm .async_login ()
222222 except NagScreen :
223223 cprint (
224- (
225- "Unable to log in. Please set up two-factor authentication for this"
226- " account."
227- ),
224+ "Unable to log in. Please set up two-factor authentication for this"
225+ " account." ,
228226 "red" ,
229227 )
230228 sys .exit ()
@@ -244,20 +242,16 @@ async def cli() -> None:
244242 )
245243 else :
246244 cprint (
247- (
248- "Not enough information provided to make a decision regarding"
249- " two-factor authentication."
250- ),
245+ "Not enough information provided to make a decision regarding"
246+ " two-factor authentication." ,
251247 "red" ,
252248 )
253249 sys .exit ()
254250
255251 if login_result == AuthResult .ENABLE_TWO_FACTOR :
256252 cprint (
257- (
258- "Unable to log in. Please set up two-factor authentication for this"
259- " account."
260- ),
253+ "Unable to log in. Please set up two-factor authentication for this"
254+ " account." ,
261255 "red" ,
262256 )
263257 sys .exit ()
@@ -347,10 +341,8 @@ async def cli() -> None:
347341 config_option : ConfigurationOption = device .settings [setting_slug ]
348342 except KeyError :
349343 cprint (
350- (
351- f"{ device .name } ({ device_id } ) does not have the setting"
352- f" { setting_slug } ."
353- ),
344+ f"{ device .name } ({ device_id } ) does not have the setting"
345+ f" { setting_slug } ." ,
354346 "red" ,
355347 )
356348 sys .exit (0 )
@@ -375,10 +367,8 @@ async def cli() -> None:
375367 typed_new_value = config_option_type .enum_from_key (new_value )
376368 except ValueError :
377369 cprint (
378- (
379- f"Acceptable valures for { setting_slug } are:"
380- f" { ', ' .join ([member_name .lower () for member_name in config_option_type .names ()])} "
381- ),
370+ f"Acceptable valures for { setting_slug } are:"
371+ f" { ', ' .join ([member_name .lower () for member_name in config_option_type .names ()])} " ,
382372 "red" ,
383373 )
384374 sys .exit (0 )
@@ -422,10 +412,8 @@ async def cli() -> None:
422412
423413 if str (reported_value ).upper () == str (new_value ).upper ():
424414 cprint (
425- (
426- f"{ config_option .name } was successfully changed to"
427- f" { new_value } for { device .name } ."
428- ),
415+ f"{ config_option .name } was successfully changed to"
416+ f" { new_value } for { device .name } ." ,
429417 "green" ,
430418 )
431419 else :
@@ -457,10 +445,8 @@ async def _async_machine_output(
457445 cprint ("Connection error." , "red" )
458446 except AuthenticationFailed :
459447 cprint (
460- (
461- "Authentication error. Check that your two factor authentication cookie"
462- " is correct."
463- ),
448+ "Authentication error. Check that your two factor authentication cookie"
449+ " is correct." ,
464450 "red" ,
465451 )
466452
0 commit comments