mirror of
https://github.com/ddworken/hishtory.git
synced 2024-11-23 00:34:27 +01:00
Move function to start of python file to make it more idiomatic
This commit is contained in:
parent
b3cb2690f3
commit
0cfa598e63
@ -10,6 +10,19 @@ import platform
|
||||
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)
|
||||
@ -31,19 +44,6 @@ else:
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user