Example #1
0
def stop_our_server():
    """ Stop our server, for shutting down nicely.
    This is faster than calling server.stop(), because in the latter
    case the server will need to timeout (0.25 s) before it sees that
    it needs to stop.
    """
    if is_our_server_running():
        try:
            server.stop()  # Post a stop message
            do_request(ADDRESS, "stopserver", 0.1)  # trigger
            print("Stopped our command server.")
        except Exception as err:
            print("Failed to stop command server:")
            print(err)
Example #2
0
def stop_our_server():
    """ Stop our server, for shutting down nicely.
    This is faster than calling server.stop(), because in the latter
    case the server will need to timeout (0.25 s) before it sees that
    it needs to stop.
    """
    if is_our_server_running():
        try:
            server.stop()  # Post a stop message
            do_request(ADDRESS, 'stopserver', 0.1)  # trigger
            print('Stopped our command server.')
        except Exception as err:
            print('Failed to stop command server:')
            print(err)
Example #3
0
def is_pyzo_server_running():
    """ Test whether the Pyzo server is running *somewhere* (not
    necesarily in this process).
    """
    try:
        res = do_request(ADDRESS, "echo", 0.2)
        return res.startswith("echo")
    except Exception:
        return False
Example #4
0
def is_pyzo_server_running():
    """ Test whether the Pyzo server is running *somewhere* (not
    necesarily in this process).
    """
    try:
        res = do_request(ADDRESS, 'echo', 0.2)
        return res.startswith('echo')
    except Exception:
        return False
Example #5
0
def handle_cmd_args():
    """ Handle command line arguments by sending them to the server.
    Returns a result string if any commands were processed, and None
    otherwise.
    """
    args = sys.argv[1:]
    request = " ".join(args)
    if "psn_" in request and not os.path.isfile(request):
        request = " ".join(args[1:])  # An OSX thing when clicking app icon
    request = request.strip()
    #
    if not request:
        return None
    else:
        # Always send to server, even if we are the ones that run the server
        try:
            return do_request(ADDRESS, request, 0.4).rstrip()
        except Exception as err:
            print("Could not process command line args:\n%s" % str(err))
            return None
Example #6
0
def handle_cmd_args():
    """ Handle command line arguments by sending them to the server.
    Returns a result string if any commands were processed, and None
    otherwise.
    """
    args = sys.argv[1:]
    request = ' '.join(args)
    if 'psn_' in request and not os.path.isfile(request):
        request = ' '.join(args[1:])  # An OSX thing when clicking app icon
    request = request.strip()
    #
    if not request:
        return None
    else:
        # Always send to server, even if we are the ones that run the server
        try:
            return do_request(ADDRESS, request, 0.4).rstrip()
        except Exception as err:
            print('Could not process command line args:\n%s' % str(err))
            return None