X-Git-Url: https://mudpy.org/gitweb?a=blobdiff_plain;f=lib%2Fmudpy%2Fmisc.py;h=b39610be5b177f959af9509ef6732974a981f9b9;hb=e27b1c4b71ab9cad6b2e41d7ff2cf41c3d8b8d3e;hp=8f6630f8b05e83a28329dd316336d2093b851462;hpb=761af6ff61bb547f76c761acbe41d0ef11d51681;p=mudpy.git diff --git a/lib/mudpy/misc.py b/lib/mudpy/misc.py index 8f6630f..b39610b 100644 --- a/lib/mudpy/misc.py +++ b/lib/mudpy/misc.py @@ -800,15 +800,15 @@ class User: # and the ansi escape to return to normal text if not just_prompt and prepend_padding: if not self.output_queue \ - or not self.output_queue[-1].endswith("\r\n"): + or not self.output_queue[-1].endswith(b"\r\n"): output = "$(eol)" + output elif not self.output_queue[-1].endswith( - "\r\n\x1b[0m\r\n" + b"\r\n\x1b[0m\r\n" ) and not self.output_queue[-1].endswith( - "\r\n\r\n" + b"\r\n\r\n" ): output = "$(eol)" + output - output += eol + unichr(27) + "[0m" + output += eol + chr(27) + "[0m" # tack on a prompt if active if self.state == "active": @@ -1354,15 +1354,15 @@ def replace_macros(user, text, is_input=False): # a dict of replacement macros macros = { "eol": "\r\n", - "bld": unichr(27) + "[1m", - "nrm": unichr(27) + "[0m", - "blk": unichr(27) + "[30m", - "blu": unichr(27) + "[34m", - "cyn": unichr(27) + "[36m", - "grn": unichr(27) + "[32m", - "mgt": unichr(27) + "[35m", - "red": unichr(27) + "[31m", - "yel": unichr(27) + "[33m", + "bld": chr(27) + "[1m", + "nrm": chr(27) + "[0m", + "blk": chr(27) + "[30m", + "blu": chr(27) + "[34m", + "cyn": chr(27) + "[36m", + "grn": chr(27) + "[32m", + "mgt": chr(27) + "[35m", + "red": chr(27) + "[31m", + "yel": chr(27) + "[33m", } # add dynamic macros where possible @@ -2442,9 +2442,8 @@ def daemonize(universe): if universe.contents["internal:process"].getboolean("daemon"): # if possible, we want to rename the process to the same as the script - # (these will need to be byte type during 2to3 migration) - new_argv = "\0".join(sys.argv) + "\0" - new_short_argv0 = os.path.basename(sys.argv[0]) + "\0" + new_argv = b"\x00".join(x.encode("utf-8") for x in sys.argv) + b"\x00" + short_argv0 = os.path.basename(sys.argv[0]).encode("utf-8") + b"\x00" # attempt the linux way first try: @@ -2463,7 +2462,7 @@ def daemonize(universe): ctypes.memmove(argc.contents, new_argv, len(new_argv)) ctypes.CDLL(ctypes.util.find_library("c")).prctl( 15, - new_short_argv0, + short_argv0, 0, 0, 0