Skip to content

Commit

Permalink
Move function to start of python file to make it more idiomatic
Browse files Browse the repository at this point in the history
  • Loading branch information
ddworken committed Feb 10, 2024
1 parent 2573551 commit b4e517a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions backend/web/landing/www/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
import sys
import os

def get_executable_tmpdir():
specified_dir = os.environ.get('TMPDIR', '')
if specified_dir:
return specified_dir
try:
if hasattr(os, 'ST_NOEXEC'):
if os.statvfs("/tmp").f_flag & os.ST_NOEXEC:
# /tmp/ is mounted as NOEXEC, so fall back to the current working directory
return os.getcwd()
except:
pass
return "/tmp/"

with urllib.request.urlopen('https://api.hishtory.dev/api/v1/download') as response:
resp_body = response.read()
download_options = json.loads(resp_body)
Expand All @@ -31,19 +44,6 @@
with urllib.request.urlopen(download_url) as response:
hishtory_binary = response.read()

def get_executable_tmpdir():
specified_dir = os.environ.get('TMPDIR', '')
if specified_dir:
return specified_dir
try:
if hasattr(os, 'ST_NOEXEC'):
if os.statvfs("/tmp").f_flag & os.ST_NOEXEC:
# /tmp/ is mounted as NOEXEC, so fall back to the current working directory
return os.getcwd()
except:
pass
return "/tmp/"

tmpFilePath = os.path.join(get_executable_tmpdir(), 'hishtory-client')
if os.path.exists(tmpFilePath):
os.remove(tmpFilePath)
Expand Down

0 comments on commit b4e517a

Please sign in to comment.