@@ -190,6 +190,7 @@ def __init__(self):
190
190
self .logger = logger .Logger ()
191
191
self .cache_monitor = None
192
192
self .logger .write ("Launching Update Manager" )
193
+ self .test_mode = os .getenv ("MINTUPDATE_TEST" )
193
194
self .settings = Gio .Settings (schema_id = "com.linuxmint.updates" )
194
195
195
196
self .is_lmde = False
@@ -2150,30 +2151,27 @@ def dummy_update(self, check, package_name, kernel=False):
2150
2151
2151
2152
# Part of check_apt_in_external_process fork
2152
2153
def handle_apt_check_test (self , queue ):
2153
- test_mode = os .getenv ("MINTUPDATE_TEST" )
2154
- if test_mode is None :
2155
- return False
2156
-
2157
- if test_mode == "error" :
2154
+ print ("SIMULATING TEST MODE:" , self .test_mode )
2155
+ if self .test_mode == "error" :
2158
2156
# See how an error from checkAPT subprocess is handled
2159
2157
raise Exception ("Testing - this is a simulated error." )
2160
- elif test_mode == "up-to-date" :
2158
+ elif self . test_mode == "up-to-date" :
2161
2159
# Simulate checkAPT finding no updates
2162
2160
queue .put ([None , []])
2163
- elif test_mode == "self-update" :
2161
+ elif self . test_mode == "self-update" :
2164
2162
# Simulate an update of mintupdate itself.
2165
2163
check = checkAPT .APTCheck ()
2166
2164
self .dummy_update (check , "mintupdate" , False )
2167
2165
queue .put ([None , list (check .updates .values ())])
2168
- elif test_mode == "updates" :
2166
+ elif self . test_mode == "updates" :
2169
2167
# Simulate some normal updates
2170
2168
check = checkAPT .APTCheck ()
2171
2169
self .dummy_update (check , "python3" , False )
2172
2170
self .dummy_update (check , "mint-meta-core" , False )
2173
2171
self .dummy_update (check , "linux-generic" , True )
2174
2172
self .dummy_update (check , "xreader" , False )
2175
2173
queue .put ([None , list (check .updates .values ())])
2176
- elif test_mode == "tracker-max-age" :
2174
+ elif self . test_mode == "tracker-max-age" :
2177
2175
# Simulate the UpdateTracker notifying about updates.
2178
2176
check = checkAPT .APTCheck ()
2179
2177
self .dummy_update (check , "dnsmasq" , False )
@@ -2203,17 +2201,17 @@ def handle_apt_check_test(self, queue):
2203
2201
def check_apt_in_external_process (self , queue ):
2204
2202
# in the queue we put: error_message (None if successful), list_of_updates (None if error)
2205
2203
try :
2206
- if self .handle_apt_check_test ( queue ) :
2207
- return
2208
-
2209
- check = checkAPT .APTCheck ()
2210
- check .find_changes ()
2211
- check .apply_l10n_descriptions ()
2212
- check .load_aliases ()
2213
- check .apply_aliases ()
2214
- check .clean_descriptions ()
2215
- updates = check .get_updates ()
2216
- queue .put ([None , updates ])
2204
+ if self .test_mode :
2205
+ self . handle_apt_check_test ( queue )
2206
+ else :
2207
+ check = checkAPT .APTCheck ()
2208
+ check .find_changes ()
2209
+ check .apply_l10n_descriptions ()
2210
+ check .load_aliases ()
2211
+ check .apply_aliases ()
2212
+ check .clean_descriptions ()
2213
+ updates = check .get_updates ()
2214
+ queue .put ([None , updates ])
2217
2215
except Exception as error :
2218
2216
error_msg = str (error ).replace ("E:" , "\n " ).strip ()
2219
2217
queue .put ([error_msg , None ])
@@ -2228,7 +2226,7 @@ def refresh_updates(self):
2228
2226
time .sleep (1 )
2229
2227
2230
2228
# Check presence of Mint layer
2231
- if os . getenv ( "MINTUPDATE_TEST" ) == "layer-error" or (not self .check_policy ()):
2229
+ if self . test_mode == "layer-error" or (not self .check_policy ()):
2232
2230
error_msg = "%s\n %s\n %s" % (_ ("Your APT configuration is corrupt." ),
2233
2231
_ ("Do not install or update anything - doing so could break your operating system!" ),
2234
2232
_ ("To switch to a different Linux Mint mirror and solve this problem, click OK." ))
0 commit comments