Skip to content

Commit

Permalink
Fix UnicodeDecodeError
Browse files Browse the repository at this point in the history
- This fixes the UnicodeDecodeError issue while generating all drives list with gen_list.py file
- Tidy up

Co-authored-by: Levi <[email protected]>
  • Loading branch information
HankMooody and l3v11 committed Jun 20, 2022
1 parent 10a4975 commit 212fd31
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gen_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
subprocess.run(['rclone', 'backend', 'drives', f'{remote}'], stdout=drives)

msg = ''
with open('drives.txt', 'r+') as f1:
with open('drives.txt', 'r+', encoding='utf8') as f1:
lines = json.loads(f1.read())
for count, item in enumerate(lines, 1):
id = item['id']
name = item['name'].strip().replace(' ', '_')
msg += f'{name} {id}\n'
time.sleep(2)

with open('drive_list', 'w') as f2:
with open('drive_list', 'w', encoding='utf8') as f2:
f2.truncate(0)
f2.write(msg)
time.sleep(2)
Expand Down

0 comments on commit 212fd31

Please sign in to comment.