8def enable(oksfile, disable, resource, session_name):
9 """Script to enable or disable (-d) Resources from the first Session of the
10 specified OKS database file"""
12 if session_name ==
"":
13 session_dals = db.get_dals(class_name=
"Session")
14 if len(session_dals) == 0:
15 print(f
"Error could not find any Session in file {oksfile}")
17 session = session_dals[0]
20 session = db.get_dal(
"Session", session_name)
22 print(f
"Error could not find Session {session_name} in file {oksfile}")
24 disabled = session.disabled
27 res_dal = db.get_dal(
"ResourceBase", res)
29 print(f
"Error could not find Resource {res} in file {oksfile}")
33 if res_dal
in disabled:
35 f
"{res} is already in disabled relationship of Session {session.id}"
39 print(f
"Adding {res} to disabled relationship of Session {session.id}")
40 disabled.append(res_dal)
42 if res_dal
not in disabled:
43 print(f
"{res} is not in disabled relationship of Session {session.id}")
47 f
"Removing {res} from disabled relationship of Session {session.id}"
49 disabled.remove(res_dal)
50 session.disabled = disabled
51 db.update_dal(session)