4040from xpra .util .system import is_distribution_variant , get_linux_distribution , is_DEB , is_RPM , is_Arch , is_free_threaded
4141from xpra .util .io import load_binary_file , get_status_output
4242
43+
44+ def warn (msg : str ) -> None :
45+ print (f"Warning: { msg } " )
46+
47+
48+ def error (msg : str ) -> None :
49+ print (f"Error: { msg } " )
50+
51+
4352if BITS != 64 :
44- print (f"Warning: { BITS } -bit architecture, only 64-bits are officially supported" )
53+ warn (f"{ BITS } -bit architecture, only 64-bits are officially supported" )
4554 for _ in range (5 ):
4655 sleep (1 )
4756 print ("." )
@@ -132,7 +141,7 @@ def check_pkgconfig() -> None:
132141 v = get_status_output ([PKG_CONFIG , "--version" ])
133142 has_pkg_config = v [0 ] == 0 and v [1 ]
134143 if not has_pkg_config :
135- print ( "WARNING: pkg-config not found!" )
144+ warn ( " pkg-config not found!" )
136145
137146
138147check_pkgconfig ()
@@ -992,19 +1001,18 @@ def show_switch_info() -> None:
9921001
9931002 def check_sane_defaults () -> None :
9941003 if x11_ENABLED and WIN32 :
995- print ( "Warning: enabling x11 on MS Windows is unlikely to work!" )
1004+ warn ( " enabling x11 on MS Windows is unlikely to work!" )
9961005 if gtk_x11_ENABLED and not x11_ENABLED :
997- print ( "Error: you must enable x11 to support gtk_x11!" )
1006+ error ( " you must enable x11 to support gtk_x11!" )
9981007 sys .exit (1 )
9991008 if client_ENABLED and not gtk3_ENABLED :
1000- print ( "Warning: client is enabled but none of the client toolkits are!?" )
1009+ warn ( " client is enabled but none of the client toolkits are!?" )
10011010 if DEFAULT and (not client_ENABLED and not server_ENABLED ):
1002- print ( "Warning: you probably want to build at least the client or server!" )
1011+ warn ( " you probably want to build at least the client or server!" )
10031012 if DEFAULT and not pillow_ENABLED :
1004- print ( "Warning: including Python Pillow is VERY STRONGLY recommended" )
1013+ warn ( " including Python Pillow is VERY STRONGLY recommended" )
10051014 if DEFAULT and (not enc_x264_ENABLED and not vpx_ENABLED ):
1006- print ("Warning: no x264 and no vpx support!" )
1007- print (" you should enable at least one of these two video encodings" )
1015+ warn ("no x264 and no vpx support! you should enable at least one of these two video encodings" )
10081016
10091017 check_sane_defaults ()
10101018
@@ -1020,7 +1028,7 @@ def check_cython3() -> None:
10201028 print (f"found Cython version { cython .__version__ } " )
10211029 version = tuple (int (vpart ) for vpart in cython .__version__ .split ('.' )[:2 ])
10221030 except (ValueError , ImportError ):
1023- print ( "WARNING: unable to detect Cython version" )
1031+ warn ( " unable to detect Cython version" )
10241032 else :
10251033 global cython_shared_ENABLED
10261034 if version < (3 , ):
@@ -1586,7 +1594,7 @@ def convert_templates(install_dir: str, subs: dict[str, str], subdirs: Sequence[
15861594 print (f"cannot create target dir { target_dir !r} : { e } " )
15871595 template_files = os .listdir (dirname )
15881596 if not template_files :
1589- print (f"Warning: no files found in { dirname !r} " )
1597+ warn (f"no files found in { dirname !r} " )
15901598 for f in sorted (template_files ):
15911599 if f .endswith ("osx.conf.in" ) and not OSX :
15921600 continue
@@ -1595,7 +1603,7 @@ def convert_templates(install_dir: str, subs: dict[str, str], subdirs: Sequence[
15951603 convert_templates (install_dir , subs , list (subdirs ) + [f ])
15961604 continue
15971605 if not (f .endswith (".in" ) or f .endswith (".conf" ) or f .endswith (".txt" ) or f .endswith (".keys" )):
1598- print (f"Warning: skipped { f !r} " )
1606+ warn (f"skipped { f !r} " )
15991607 continue
16001608 with open (filename , "r" , encoding = "latin1" ) as f_in :
16011609 template = f_in .read ()
@@ -1608,6 +1616,8 @@ def convert_templates(install_dir: str, subs: dict[str, str], subdirs: Sequence[
16081616 try :
16091617 config_data = template % subs
16101618 except ValueError :
1619+ # not using error() — the raise below causes a non-zero exit,
1620+ # which log_command() already surfaces via show_tail()
16111621 print (f"error applying substitutions from { filename !r} to { target_file !r} :" )
16121622 print (f"{ config_data !r} " )
16131623 print (f"{ subs !r} " )
@@ -1743,7 +1753,7 @@ def clean() -> None:
17431753 if fpath not in CLEAN_FILES :
17441754 CLEAN_FILES .append (fpath )
17451755 continue
1746- print (f"warning unexpected file in source tree: { fpath } with ext={ ext } " )
1756+ warn (f"unexpected file in source tree: { fpath } with ext={ ext } " )
17471757 for x in CLEAN_FILES :
17481758 filename = os .path .join (os .getcwd (), x .replace ("/" , os .path .sep ))
17491759 if os .path .exists (filename ):
@@ -1848,7 +1858,7 @@ def add_dir(base: str, defs) -> None:
18481858 if os .path .exists (filename ):
18491859 add_data_files (base , [filename ])
18501860 else :
1851- print (f"Warning: missing { filename !r} " )
1861+ warn (f"missing { filename !r} " )
18521862 else :
18531863 assert isinstance (defs , dict )
18541864 for d , sub in defs .items ():
@@ -1875,8 +1885,7 @@ def add_DLLs(*dll_names: str) -> None:
18751885 try :
18761886 do_add_DLLs ("lib" , * dll_names )
18771887 except Exception as e :
1878- print (f"Error: failed to add DLLs: { dll_names } " )
1879- print (f" { e } " )
1888+ error (f"failed to add DLLs: { dll_names } : { e } " )
18801889 sys .exit (1 )
18811890
18821891 def do_add_DLLs (prefix = "lib" , * dll_names : str ) -> None :
@@ -1919,9 +1928,8 @@ def do_add_DLLs(prefix="lib", *dll_names: str) -> None:
19191928 dll_files .append (dll_path )
19201929 dll_names .remove (dll_name )
19211930 if dll_names :
1922- print ("some DLLs could not be found:" )
1923- for x in dll_names :
1924- print (f" - { prefix } { x } *.dll" )
1931+ missing = ", " .join (f"{ prefix } { x } *.dll" for x in dll_names )
1932+ warn (f"some DLLs could not be found: { missing } " )
19251933 add_data_files ("" , dll_files )
19261934
19271935 # list of DLLs we want to include, without the "lib" prefix, or the version and extension
@@ -2306,8 +2314,7 @@ def add_service_exe(script, icon, base_name) -> None:
23062314 try :
23072315 import OpenGL_accelerate #@UnresolvedImport
23082316 except ImportError as e :
2309- print ("Warning: missing OpenGL_accelerate module" )
2310- print (f" { e } " )
2317+ warn (f"missing OpenGL_accelerate module: { e } " )
23112318 else :
23122319 glmodules ["OpenGL_accelerate" ] = OpenGL_accelerate
23132320 for module_name , module in glmodules .items ():
0 commit comments