Skip to content

Commit

Permalink
wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe committed Sep 17, 2024
1 parent 8c164d1 commit 494c649
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions add_release_prefix.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
import os
import sys
import time

directory = os.path.join("target", "bundled")
prefix = sys.argv[1] # assuming prefix is passed as the first argument
max_retries = 5 # Number of retries for a locked file
delay = 2 # Delay in seconds between retries
prefix = sys.argv[1]

# Iterate over files in the directory
for filename in os.listdir(directory):
old_file = os.path.join(directory, filename) # ensure you access the full file path
new_file = os.path.join(directory, prefix + filename) # add prefix to the filename

retries = 0
while retries < max_retries:
try:
os.rename(old_file, new_file)
print(f"Renamed: {old_file} -> {new_file}")
break
except PermissionError:
print(f"PermissionError: File '{old_file}' is being used. Retrying in {delay} seconds...")
retries += 1
time.sleep(delay) # Wait before retrying
except Exception as e:
print(f"Error: {e}")
break
else:
print(f"Failed to rename '{old_file}' after {max_retries} attempts.")
old_file = os.path.join(directory)
new_file = os.path.join(directory, prefix + filename)
os.rename(old_file, new_file)

print(f"Prefix '{prefix}' added to release files.")
print(f"Prefix '{prefix}' added to release files")

0 comments on commit 494c649

Please sign in to comment.