55import click
66import schedule
77
8+ from leeteasy .constant import Constant
89from leeteasy .services .notification_service import Notifier
910from leeteasy .utils .validatiors import TimeValidator
1011
1415 '-d' ,
1516 '--difficulty' ,
1617 type = click .Choice (['Medium' , 'Hard' ], case_sensitive = False ),
17- help = 'Additional problem difficulty for notification.'
18+ help = 'Additional problem difficulty for notification.' ,
1819)
1920@click .option (
20- " --sleep_duration" ,
21- default = 3600 ,
22- type = click .IntRange (1 , 3600 , clamp = True ),
23- help = 'Sleep duration in seconds.'
21+ ' --sleep_duration' ,
22+ default = Constant . DEFAULT_SLEEP ,
23+ type = click .IntRange (1 , Constant . DEFAULT_SLEEP , clamp = True ),
24+ help = 'Sleep duration in seconds.' ,
2425)
2526@click .argument ('time' )
2627def execute_start (time , difficulty , sleep_duration ) -> None :
@@ -33,30 +34,32 @@ def execute_start(time, difficulty, sleep_duration) -> None:
3334 Notifier .target_difficulty .append (difficulty )
3435 schedule .every ().day .at (time ).do (Notifier .notify )
3536
36- while True :
37+ while True : # NOQA: WPS457
3738 schedule .run_pending ()
3839 clock .sleep (sleep_duration )
3940
4041
4142@click .command ('stop' )
4243def execute_stop () -> None :
43- """Stops leeteasy process"""
44+ """Stop leeteasy process. """
4445 os .system ('pkill -9 -f leeteasy' )
4546
4647
4748@click .group ('leeteasy' )
4849def execute_root ():
49- """v0.4.0 | supported version strings: 0.7.2"""
50- pass
50+ """Group child command."""
5151
5252
5353execute_root .add_command (execute_start )
5454execute_root .add_command (execute_stop )
5555
5656if __name__ == '__main__' :
5757 if platform != 'win32' :
58- import pwd
58+ import pwd # NOQA: WPS433
5959
60- os .environ [
61- 'DBUS_SESSION_BUS_ADDRESS' ] = f'unix:path=/run/user/{ pwd .getpwuid (os .getuid ()).pw_uid } /bus' # NOQA: E501
60+ bus_addr = 'unix:path=/run/user/{0}/bus' .format (
61+ pwd .getpwuid (os .getuid ()).pw_uid ,
62+ )
63+
64+ os .environ ['DBUS_SESSION_BUS_ADDRESS' ] = bus_addr
6265 execute_root ()
0 commit comments