Skip to content

Commit 424c652

Browse files
Release 0.4.2
1 parent 8ab2852 commit 424c652

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

setup.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,25 @@ def url_retrieve(url: str, outfile: Path, overwrite: bool = False):
7373
if OPENPLANET_FOLDER.exists():
7474
# copy the OpenPlanet script:
7575
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)
8291
except Exception as e:
8392
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)}.")
8695
else:
8796
# warn the user that OpenPlanet couldn't be found:
8897
print(f"The OpenPlanet folder was not found at {OPENPLANET_FOLDER}. \

0 commit comments

Comments
 (0)