@@ -73,16 +73,25 @@ def url_retrieve(url: str, outfile: Path, overwrite: bool = False):
73
73
if OPENPLANET_FOLDER .exists ():
74
74
# copy the OpenPlanet script:
75
75
try :
76
- OP_SCRIPTS_FOLDER = OPENPLANET_FOLDER / "Scripts"
77
- OP_SCRIPTS_FOLDER .mkdir (parents = True , exist_ok = True )
78
- TM20_SCRIPT_FILE = RESOURCES_FOLDER / 'Scripts' / 'Plugin_GrabData_0_2.as'
79
- TM20_SCRIPT_FILE_SIG = RESOURCES_FOLDER / 'Scripts' / 'Plugin_GrabData_0_2.as.sig'
80
- copy2 (TM20_SCRIPT_FILE , OP_SCRIPTS_FOLDER )
81
- copy2 (TM20_SCRIPT_FILE_SIG , OP_SCRIPTS_FOLDER )
76
+ # remove old script if found
77
+ OP_SCRIPTS_FOLDER = OPENPLANET_FOLDER / 'Scripts'
78
+ if OP_SCRIPTS_FOLDER .exists ():
79
+ to_remove = [OP_SCRIPTS_FOLDER / 'Plugin_GrabData_0_1.as' ,
80
+ OP_SCRIPTS_FOLDER / 'Plugin_GrabData_0_1.as.sig' ,
81
+ OP_SCRIPTS_FOLDER / 'Plugin_GrabData_0_2.as' ,
82
+ OP_SCRIPTS_FOLDER / 'Plugin_GrabData_0_2.as.sig' ]
83
+ for old_file in to_remove :
84
+ if old_file .exists ():
85
+ old_file .unlink ()
86
+ # copy new plugin
87
+ OP_PLUGINS_FOLDER = OPENPLANET_FOLDER / 'Plugins'
88
+ OP_PLUGINS_FOLDER .mkdir (parents = True , exist_ok = True )
89
+ TM20_PLUGIN = RESOURCES_FOLDER / 'Plugins' / 'TMRL_GrabData.op'
90
+ copy2 (TM20_PLUGIN , OP_PLUGINS_FOLDER )
82
91
except Exception as e :
83
92
print (
84
- f"An exception was caught when trying to copy the OpenPlanet script and signature automatically. \
85
- Please copy these files manually for TrackMania 2020 support. The caught exception was: { str (e )} ." )
93
+ f"An exception was caught when trying to copy the OpenPlanet plugin automatically. \
94
+ Please copy the plugin manually for TrackMania 2020 support. The caught exception was: { str (e )} ." )
86
95
else :
87
96
# warn the user that OpenPlanet couldn't be found:
88
97
print (f"The OpenPlanet folder was not found at { OPENPLANET_FOLDER } . \
0 commit comments