forked from shaba/openuds
Added /opt/homebrew/bin as path in mac os x for newer brew installs
This commit is contained in:
parent
aef8c637ec
commit
0b0c72e65b
@ -31,6 +31,7 @@
|
|||||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||||
'''
|
'''
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import platform
|
import platform
|
||||||
import time
|
import time
|
||||||
import webbrowser
|
import webbrowser
|
||||||
@ -262,7 +263,7 @@ def sslError(hostname: str, serial):
|
|||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
return approved
|
return approved
|
||||||
|
|
||||||
|
# Used only if command line says so
|
||||||
def minimal(api: RestApi, ticket: str, scrambler: str):
|
def minimal(api: RestApi, ticket: str, scrambler: str):
|
||||||
try:
|
try:
|
||||||
logger.info('M1 Execution')
|
logger.info('M1 Execution')
|
||||||
@ -319,11 +320,20 @@ if __name__ == "__main__":
|
|||||||
if 'darwin' not in sys.platform:
|
if 'darwin' not in sys.platform:
|
||||||
logger.debug('Mac OS *NOT* Detected')
|
logger.debug('Mac OS *NOT* Detected')
|
||||||
app.setStyle('plastique') # type: ignore
|
app.setStyle('plastique') # type: ignore
|
||||||
|
else:
|
||||||
|
logger.debug('Platform is Mac OS, adding homebrew possible paths')
|
||||||
|
os.environ['PATH'] += os.pathsep.join(['/opt/homebrew/bin'])
|
||||||
|
logger.debug('Now path is %s', os.environ['PATH'])
|
||||||
|
|
||||||
# First parameter must be url
|
# First parameter must be url
|
||||||
|
useMinimal = False
|
||||||
try:
|
try:
|
||||||
uri = sys.argv[1]
|
uri = sys.argv[1]
|
||||||
|
|
||||||
|
if uri == '--minimal':
|
||||||
|
useMinimal = True
|
||||||
|
uri = sys.argv[2] # And get URI
|
||||||
|
|
||||||
if uri == '--test':
|
if uri == '--test':
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
@ -355,13 +365,6 @@ if __name__ == "__main__":
|
|||||||
'{}://{}/uds/rest/client'.format(['http', 'https'][ssl], host), sslError
|
'{}://{}/uds/rest/client'.format(['http', 'https'][ssl], host), sslError
|
||||||
)
|
)
|
||||||
|
|
||||||
# try:
|
|
||||||
# if platform.mac_ver()[2] == 'arm64':
|
|
||||||
# minimal(api, ticket, scrambler)
|
|
||||||
# sys.exit(0)
|
|
||||||
# except Exception:
|
|
||||||
# pass # Ignore check (should not be any problem)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.debug('Starting execution')
|
logger.debug('Starting execution')
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ import stat
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import base64
|
import base64
|
||||||
|
import typing
|
||||||
|
|
||||||
from .log import logger
|
from .log import logger
|
||||||
|
|
||||||
_unlinkFiles = []
|
_unlinkFiles: typing.List[str] = []
|
||||||
_tasksToWait = []
|
_tasksToWait: typing.List[typing.Any] = []
|
||||||
_execBeforeExit = []
|
_execBeforeExit: typing.List[typing.Callable[[],None]] = []
|
||||||
|
|
||||||
sys_fs_enc = sys.getfilesystemencoding() or 'mbcs'
|
sys_fs_enc = sys.getfilesystemencoding() or 'mbcs'
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ nVgtClKcDDlSaBsO875WDR0CAwEAAQ==
|
|||||||
-----END PUBLIC KEY-----'''
|
-----END PUBLIC KEY-----'''
|
||||||
|
|
||||||
|
|
||||||
def saveTempFile(content, filename=None):
|
def saveTempFile(content: str, filename: typing.Optional[str]=None) -> str:
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
|
filename = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
|
||||||
filename = filename + '.uds'
|
filename = filename + '.uds'
|
||||||
@ -79,7 +79,7 @@ def saveTempFile(content, filename=None):
|
|||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
def readTempFile(filename):
|
def readTempFile(filename: str) -> typing.Optional[str]:
|
||||||
filename = os.path.join(tempfile.gettempdir(), filename)
|
filename = os.path.join(tempfile.gettempdir(), filename)
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
@ -88,7 +88,7 @@ def readTempFile(filename):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def testServer(host, port, timeOut=4):
|
def testServer(host: str, port: typing.Union[str, int], timeOut: int=4) -> bool:
|
||||||
try:
|
try:
|
||||||
sock = socket.create_connection((host, int(port)), timeOut)
|
sock = socket.create_connection((host, int(port)), timeOut)
|
||||||
sock.close()
|
sock.close()
|
||||||
@ -97,9 +97,9 @@ def testServer(host, port, timeOut=4):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def findApp(appName, extraPath=None):
|
def findApp(appName: str, extraPath:typing.Optional[str] = None) -> typing.Optional[str]:
|
||||||
searchPath = os.environ['PATH'].split(os.pathsep)
|
searchPath = os.environ['PATH'].split(os.pathsep)
|
||||||
if extraPath is not None:
|
if extraPath:
|
||||||
searchPath += list(extraPath)
|
searchPath += list(extraPath)
|
||||||
|
|
||||||
for path in searchPath:
|
for path in searchPath:
|
||||||
@ -109,7 +109,7 @@ def findApp(appName, extraPath=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def getHostName():
|
def getHostName() -> str:
|
||||||
'''
|
'''
|
||||||
Returns current host name
|
Returns current host name
|
||||||
In fact, it's a wrapper for socket.gethostname()
|
In fact, it's a wrapper for socket.gethostname()
|
||||||
@ -121,14 +121,14 @@ def getHostName():
|
|||||||
# Queing operations (to be executed before exit)
|
# Queing operations (to be executed before exit)
|
||||||
|
|
||||||
|
|
||||||
def addFileToUnlink(filename):
|
def addFileToUnlink(filename: str) -> None:
|
||||||
'''
|
'''
|
||||||
Adds a file to the wait-and-unlink list
|
Adds a file to the wait-and-unlink list
|
||||||
'''
|
'''
|
||||||
_unlinkFiles.append(filename)
|
_unlinkFiles.append(filename)
|
||||||
|
|
||||||
|
|
||||||
def unlinkFiles():
|
def unlinkFiles() -> None:
|
||||||
'''
|
'''
|
||||||
Removes all wait-and-unlink files
|
Removes all wait-and-unlink files
|
||||||
'''
|
'''
|
||||||
@ -142,11 +142,11 @@ def unlinkFiles():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def addTaskToWait(taks):
|
def addTaskToWait(taks: typing.Any) -> None:
|
||||||
_tasksToWait.append(taks)
|
_tasksToWait.append(taks)
|
||||||
|
|
||||||
|
|
||||||
def waitForTasks():
|
def waitForTasks() -> None:
|
||||||
for t in _tasksToWait:
|
for t in _tasksToWait:
|
||||||
try:
|
try:
|
||||||
if hasattr(t, 'join'):
|
if hasattr(t, 'join'):
|
||||||
@ -157,16 +157,16 @@ def waitForTasks():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def addExecBeforeExit(fnc):
|
def addExecBeforeExit(fnc: typing.Callable[[], None]) -> None:
|
||||||
_execBeforeExit.append(fnc)
|
_execBeforeExit.append(fnc)
|
||||||
|
|
||||||
|
|
||||||
def execBeforeExit():
|
def execBeforeExit() -> None:
|
||||||
for fnc in _execBeforeExit:
|
for fnc in _execBeforeExit:
|
||||||
fnc.__call__()
|
fnc()
|
||||||
|
|
||||||
|
|
||||||
def verifySignature(script, signature):
|
def verifySignature(script: bytes, signature: bytes) -> bool:
|
||||||
'''
|
'''
|
||||||
Verifies with a public key from whom the data came that it was indeed
|
Verifies with a public key from whom the data came that it was indeed
|
||||||
signed by their private key
|
signed by their private key
|
||||||
|
Loading…
Reference in New Issue
Block a user