@@ -56,7 +56,7 @@ def _set_sys_property(property_name: str, value: str):
5656 Set a sys_property in the instance.
5757
5858 """
59- instance = SNowInstance ()
59+ instance = SNowInstance (check_installed = False )
6060
6161 property = table_api_call (
6262 instance = instance ,
@@ -82,20 +82,7 @@ def _set_sys_property(property_name: str, value: str):
8282 assert property ["result" ]["value" ] == value , f"Error setting { property_name } ."
8383
8484
85- def _get_sys_property (property_name : str ) -> str :
86- """
87- Get a sys_property from the instance.
88-
89- """
90- instance = SNowInstance ()
91-
92- property_value = table_api_call (
93- instance = instance ,
94- table = "sys_properties" ,
95- params = {"sysparm_query" : f"name={ property_name } " , "sysparm_fields" : "value" },
96- )["result" ][0 ]["value" ]
97-
98- return property_value
85+ # Remove the _get_sys_property function as it's now in instance.py
9986
10087
10188def _install_update_set (path : str , name : str ):
@@ -113,7 +100,7 @@ def _install_update_set(path: str, name: str):
113100
114101 """
115102 with sync_playwright () as playwright :
116- instance = SNowInstance ()
103+ instance = SNowInstance (check_installed = False )
117104 browser = playwright .chromium .launch (headless = True , slow_mo = 1000 )
118105 page = browser .new_page ()
119106 url_login (instance , page )
@@ -352,7 +339,7 @@ def setup_knowledge_bases():
352339
353340 """
354341 # Get the ServiceNow instance
355- instance = SNowInstance ()
342+ instance = SNowInstance (check_installed = False )
356343 # Mapping between knowledge base name and filepath + whether or not to disable comments + whether or not to add article name
357344 knowledge_bases = {
358345 KB_NAME : (KB_FILEPATH , True , False ),
@@ -419,7 +406,7 @@ def check_workflows_installed():
419406 """
420407 expected_workflow_names = [x ["name" ] for x in WORKFLOWS .values ()]
421408 workflows = table_api_call (
422- instance = SNowInstance (),
409+ instance = SNowInstance (check_installed = False ),
423410 table = "wf_workflow" ,
424411 params = {
425412 "sysparm_query" : "nameIN" + "," .join (expected_workflow_names ),
@@ -611,7 +598,7 @@ def setup_list_columns():
611598 }
612599
613600 logging .info ("... Creating a new user account to validate list columns" )
614- admin_instance = SNowInstance ()
601+ admin_instance = SNowInstance (check_installed = False )
615602 username , password , usysid = create_user (instance = admin_instance )
616603 user_instance = SNowInstance (snow_credentials = (username , password ))
617604
@@ -717,7 +704,7 @@ def setup_form_fields():
717704 }
718705
719706 logging .info ("... Creating a new user account to validate form fields" )
720- admin_instance = SNowInstance ()
707+ admin_instance = SNowInstance (check_installed = False )
721708 username , password , usysid = create_user (instance = admin_instance )
722709 user_instance = SNowInstance (snow_credentials = (username , password ))
723710
@@ -779,7 +766,7 @@ def check_instance_release_support():
779766 bool: True if the version is supported, False otherwise.
780767
781768 """
782- instance = SNowInstance ()
769+ instance = SNowInstance (check_installed = False )
783770 version_info = instance .release_version
784771 if version_info ["build name" ] not in SNOW_SUPPORTED_RELEASES :
785772 logging .error (
@@ -816,7 +803,11 @@ def disable_welcome_help_popup():
816803 Disable the welcome help popup
817804
818805 """
819- set_user_preference (instance = SNowInstance (), key = "overview_help.visited.navui" , value = "true" )
806+ set_user_preference (
807+ instance = SNowInstance (check_installed = False ),
808+ key = "overview_help.visited.navui" ,
809+ value = "true" ,
810+ )
820811 logging .info ("Welcome help popup disabled." )
821812
822813
@@ -841,24 +832,24 @@ def setup_ui_themes():
841832 logging .info ("Setting default UI theme" )
842833 _set_sys_property (
843834 property_name = "glide.ui.polaris.theme.custom" ,
844- value = get_workarena_theme_variants (SNowInstance ())[0 ]["theme.sys_id" ],
835+ value = get_workarena_theme_variants (SNowInstance (check_installed = False ))[0 ]["theme.sys_id" ],
845836 )
846837
847838 # Set admin user's theme variant
848839 # ... get user's sysid
849840 admin_user = table_api_call (
850- instance = SNowInstance (),
841+ instance = SNowInstance (check_installed = False ),
851842 table = "sys_user" ,
852843 params = {"sysparm_query" : "user_name=admin" , "sysparm_fields" : "sys_id" },
853844 )["result" ][0 ]
854845 # ... set user preference
855846 set_user_preference (
856- instance = SNowInstance (),
847+ instance = SNowInstance (check_installed = False ),
857848 user = admin_user ["sys_id" ],
858849 key = "glide.ui.polaris.theme.variant" ,
859850 value = [
860851 x ["style.sys_id" ]
861- for x in get_workarena_theme_variants (SNowInstance ())
852+ for x in get_workarena_theme_variants (SNowInstance (check_installed = False ))
862853 if x ["style.name" ] == "Workarena"
863854 ][0 ],
864855 )
@@ -870,7 +861,7 @@ def check_ui_themes_installed():
870861
871862 """
872863 expected_variants = set ([v .lower () for v in UI_THEMES_UPDATE_SET ["variants" ]])
873- installed_themes = get_workarena_theme_variants (SNowInstance ())
864+ installed_themes = get_workarena_theme_variants (SNowInstance (check_installed = False ))
874865 installed_themes = set ([t ["style.name" ].lower () for t in installed_themes ])
875866
876867 assert (
@@ -893,7 +884,7 @@ def wipe_system_admin_preferences():
893884 """
894885 logging .info ("Wiping all system admin preferences" )
895886 sys_admin_prefs = table_api_call (
896- instance = SNowInstance (),
887+ instance = SNowInstance (check_installed = False ),
897888 table = "sys_user_preference" ,
898889 params = {"sysparm_query" : "user.user_name=admin" , "sysparm_fields" : "sys_id,name" },
899890 )["result" ]
@@ -903,7 +894,9 @@ def wipe_system_admin_preferences():
903894 for pref in sys_admin_prefs :
904895 logging .info (f"...... deleting { pref ['name' ]} " )
905896 table_api_call (
906- instance = SNowInstance (), table = f"sys_user_preference/{ pref ['sys_id' ]} " , method = "DELETE"
897+ instance = SNowInstance (check_installed = False ),
898+ table = f"sys_user_preference/{ pref ['sys_id' ]} " ,
899+ method = "DELETE" ,
907900 )
908901
909902
@@ -926,7 +919,7 @@ def patch_report_filters():
926919 """
927920 logging .info ("Patching reports with date filter..." )
928921
929- instance = SNowInstance ()
922+ instance = SNowInstance (check_installed = False )
930923
931924 # Get all reports that are not already patched
932925 reports = table_api_call (
@@ -1054,7 +1047,8 @@ def main():
10541047 logging .basicConfig (level = logging .INFO )
10551048
10561049 try :
1057- past_install_date = _get_sys_property ("workarena.installation.date" )
1050+ instance = SNowInstance (check_installed = False )
1051+ past_install_date = instance ._get_sys_property ("workarena.installation.date" )
10581052 logging .info (f"Detected previous installation on { past_install_date } . Reinstalling..." )
10591053 except :
10601054 past_install_date = "never"
@@ -1068,7 +1062,7 @@ def main():
10681062██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
10691063 ███ ███ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███████ ██ ████ ██ ██
10701064
1071- Instance: { SNowInstance ().snow_url }
1065+ Instance: { SNowInstance (check_installed = False ).snow_url }
10721066Previous installation: { past_install_date }
10731067
10741068"""
0 commit comments