def __init__(self, env, **kwargs): """ Constructor. Parameters ---------- env: Environment The environment this pool is using. Keyworded parameters -------------------- size: integer Size of the pool, i.e. the number of servers. Default: 10. capacity: integer Capacity of each server. Default: 10. kind: string Kind of servers in this pool. Default: 'regular'. """ # set the default arguments size = kwargs['size'] if 'size' in kwargs else 10 capacity = kwargs['capacity'] if 'capacity' in kwargs else 10 kind = kwargs['kind'] if 'kind' in kwargs else 'regular' # construct a new pool self._pool = [ Server(env, capacity, uuid=uuid4(), kind=kind) for _ in range(size) ] # assign some parameters as properties self._kind = kind # disabled state of this pool self._disabled = False # random state of this pool self._random = False # stuck loadbalancing state of this pool self._stuck = False self.stuckserver = None
parser.print_help() sys.exit(1) outputDirectory = options.outputDirectory headers = "Server Name|User Name|Gecos|Locked|Groups|Sudo Rights" appServersList = parseCSV(options.serversListFile) for appName, serversList in appServersList.iteritems(): if options.verbose: printTitle("Working on application {0}".format(appName), True) with open(os.path.join(outputDirectory, "{0}.psv".format(appName)), 'w') as f: f.write(headers + os.linesep) for serverName in serversList: if options.verbose: printTitle("Parsing server {0}".format(serverName)) print headers server = Server(serverName) users = server.getUsers() for user in users: row = "{0}|{1}|{2}|{3}|{4}|{5}".format( server.getName(), user.name, user.gecos, user.isLocked, " ".join(user.groups), ";".join(str(v).strip() for v in user.sudoPerms)) if options.verbose: print row f.write(row + os.linesep)
headers = "Server Name|User Name|Gecos|Locked|Groups|Sudo Rights" appServersList = parseCSV(options.serversListFile) for appName,serversList in appServersList.iteritems(): if options.verbose: printTitle("Working on application {0}".format(appName), True) with open(os.path.join(outputDirectory, "{0}.psv".format(appName)), 'w') as f: f.write(headers+ os.linesep) for serverName in serversList: if options.verbose: printTitle("Parsing server {0}".format(serverName)) print headers server = Server(serverName) users = server.getUsers() for user in users: row = "{0}|{1}|{2}|{3}|{4}|{5}".format( server.getName(), user.name, user.gecos, user.isLocked, " ".join(user.groups), ";".join(str(v).strip() for v in user.sudoPerms) ) if options.verbose: print row f.write(row + os.linesep)
import sys from lib.Server import Server # from lib.ServerManager import ServerManager gameServer = Server('127.0.0.1', 3001) gameServer.start() # gameServer = ServerManager('127.0.0.1', 3001) # gameServer.start()
def test_server_getname(self): server = Server('aws-devbox-root') self.assertEqual(server.getName(), 'aws-devbox-root')
def test_server_getOSType(self): server = Server('aws-devbox-root') self.assertEqual(server.getOSType(), 'linux')
def main(): s = Server(3030) s.on_connection(lambda socket: socket.on( "test", lambda data: socket.to("Luka").emit("test", "Daa"))) s.listen()
import threading from threading import Thread import lib.Ngrok from lib import bottle from lib.MicrophoneStream import MicrophoneStream from lib.Server import Server myapp = Server() bgm_thread = threading.Thread(target=myapp.play_bgm) ngrok = lib.Ngrok.Ngrok() threading.Thread(target=myapp.stream_speach).start() bottle.route("/messenger", method=['POST'])(myapp.messengerFromFirebase) bottle.route("/appNotification", method=['POST'])(myapp.app_notification) bottle.run(host='localhost', port=9000) #time.sleep(10)
from lib.Server import Server if __name__ == '__main__': server = Server() server.create_server('0.0.0.0', 4455)