Fix broken pip backup/restore
This commit is contained in:
parent
09b2fdd6d2
commit
bad56be7ca
1 changed files with 11 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
@ -49,14 +50,20 @@ def configure_git():
|
||||||
|
|
||||||
def backup_pip():
|
def backup_pip():
|
||||||
pip = pathlib.Path.home() / ".config" / "pip"
|
pip = pathlib.Path.home() / ".config" / "pip"
|
||||||
|
pip_bak = pathlib.Path.home() / ".config" / "pip.bak"
|
||||||
|
if pip_bak.exists():
|
||||||
|
print("Removing stray backup directory...")
|
||||||
|
shutil.rmtree(pip_bak)
|
||||||
|
|
||||||
if pip.exists():
|
if pip.exists():
|
||||||
pip.rename("pip.bak")
|
pip.rename(pip_bak)
|
||||||
|
|
||||||
|
|
||||||
def restore_pip():
|
def restore_pip():
|
||||||
pip = pathlib.Path.home() / ".config" / "pip.bak"
|
pip = pathlib.Path.home() / ".config" / "pip"
|
||||||
if pip.exists():
|
pip_bak = pathlib.Path.home() / ".config" / "pip.bak"
|
||||||
pip.rename("pip")
|
if pip_bak.exists():
|
||||||
|
pip_bak.rename(pip)
|
||||||
|
|
||||||
|
|
||||||
def configure_python():
|
def configure_python():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue