1919 help = """Check unnecessary directories in attic."""
2020)
2121def check (
22- check_attic : Annotated [str , typer .Argument ()] = '' ,
2322 school : Annotated [str , typer .Option ("--school" , "-s" )] = None ,
2423 ):
2524
26- result = check_attic_dir ()
27- attic_dir = "/srv/samba/schools/default-school/students/attic"
25+
26+ try :
27+ result = check_attic_dir (school = school )
28+ except Exception as e :
29+ typer .secho (str (e ), fg = typer .colors .RED )
30+ return
2831
2932 attic = Table (title = f"User's status in attic" )
3033 attic .add_column ("Username" , style = "cyan" )
31- attic .add_column ("School" , style = "cyan" )
3234 attic .add_column ("Status" , style = "yellow" )
35+ attic .add_column ("School" , style = "cyan" )
3336 attic .add_column ("Directory path" , style = "green" )
3437
3538 to_delete = []
@@ -48,11 +51,13 @@ def check(
4851 status = f"Account { details ['status' ]} from { details ['start' ]} to { details ['end' ]} "
4952 else :
5053 status = f"Account { details ['status' ]} since { details ['start' ]} "
54+ attic_dir = f"//{ SAMBA_DOMAIN } /{ details ['school' ]} /students/attic/{ user } "
5155 else :
5256 status = "No information found"
57+ attic_dir = ""
5358
54- data .append ([user , status , details ['school' ], f" { attic_dir } / { user } " ])
55- attic .add_row (user , status , details ['school' ], f" { attic_dir } / { user } " )
59+ data .append ([user , status , details ['school' ], attic_dir ])
60+ attic .add_row (user , status , details ['school' ], attic_dir )
5661
5762 if state .format :
5863 printf .format (data )
@@ -64,7 +69,6 @@ def check(
6469 typer .confirm (f"You can delete the unnecessary directory by running:\n \n { cmd } \n Run this command now ?" , abort = True )
6570 client = LMNSMBClient ()
6671 for entry in to_delete :
67- print (entry )
6872 client .switch (entry ['school' ])
6973 client .deltree (f"students/attic/{ entry ['user' ]} " )
7074 typer .echo (typer .style (f"Attic directory of { user } deleted!" , fg = typer .colors .RED ))
0 commit comments