Skip to content

Commit

Permalink
Update.py: Replace distutils with os.makedirs and fix flake8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TunaLobster committed Oct 8, 2024
1 parent 819da9d commit 3d74a67
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,20 @@
from concurrent.futures import ThreadPoolExecutor
from typing import Optional, Dict, List

if sys.version_info <= (3,11):
import distutils
from frontend.scripts import get_discourse_posts
import rst_table

from codecs import open
from datetime import datetime

try:
from sphinx.application import Sphinx
from sphinx.application import Sphinx # noqa: F401
except ModuleNotFoundError as e:
print("Please make sure that you have run the SphinxSetup script for your system and that you have activated the arudpilot-wiki-venv if it was created on your system")
print("Please make sure that you have run the SphinxSetup script for your system and that you have activated the",
"arudpilot-wiki-venv if it was created on your system")
print(e)
sys.exit(1)

from codecs import open
from datetime import datetime
# while flake8 says this is unused, distutils.dir_util.mkpath fails
# without the following import on old versions of Python:
if sys.version_info <= (3, 11):
from distutils import dir_util # noqa: F401

from frontend.scripts import get_discourse_posts
import rst_table

if sys.version_info < (3, 8):
print("Minimum python version is 3.8")
sys.exit(1)
Expand Down Expand Up @@ -372,14 +366,14 @@ def make_backup(site, destdir, backupdestdir):
debug('Backing up: %s' % wiki)

targetdir = os.path.join(destdir, wiki)
distutils.dir_util.mkpath(targetdir)
os.makedirs(targetdir, exist_ok=True)

if not os.path.exists(targetdir):
fatal("FAIL backup when looking for folder %s" % targetdir)

bkdir = os.path.join(backupdestdir, str(building_time + '-wiki-bkp'), str(wiki))
debug('Checking %s' % bkdir)
distutils.dir_util.mkpath(bkdir)
os.makedirs(bkdir, exist_ok=True)
debug('Copying %s into %s' % (targetdir, bkdir))
try:
subprocess.check_call(["rsync", "-a", "--delete", targetdir + "/", bkdir])
Expand Down

0 comments on commit 3d74a67

Please sign in to comment.