Example #1
0
def main():
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger()

    ap = argparse.ArgumentParser(description='A miner server.')

    ap.add_argument('--server_addr', type=str, nargs='?', default='localhost',
                    help='Address the server should bind to.')
    ap.add_argument('--server_port', type=int, nargs='?', default=8993,
                    help='The port the server listen to.')
    ap.add_argument('--board', type=str, nargs='?', default='Gossiping',
                    help='The Board you want to mine.')
    ap.add_argument('--number', type=int, nargs='?', default=2,
                    help='The Pages you want to mine.')
    ap.add_argument('--fetch_path', type=str, nargs='?', default='./',
                    help='The Place you want to put your mining file')
    ap.add_argument('--mining', type=bool, nargs='?', default=False,
                    help='Mining or not')
    ap.add_argument('--storage_path', type=str, nargs='?', default='./storage',
                    help='Path to storeage the mirror of the ptt server.')
    ap.add_argument('--cache_size', type=int, nargs='?', default=5000,
                    help='Number of documents should be cached in the RAM.')
    ap.add_argument('--miner2', type=bool, nargs='?', default=False,
                    help='Use the version 2 miner or not.')
    opts = ap.parse_args()

    if opts.miner2:
        backend = L2Miner(logging.getLogger('miner'),
                          opts.cache_size, opts.storage_path)
    else:
        current_dir = os.getcwd()
        if opts.mining == True:
            miner = BBSCrawler(opts.board,opts.number,opts.fetch_path)
            miner.getAllPagesInTheBoard()
            miner.getContent()
        os.chdir(current_dir)
        backend = BuildData(opts.fetch_path + opts.board)
        os.chdir(current_dir)

    server = Server(backend, opts.server_addr, opts.server_port)
    try:
        server.run()
    except KeyboardInterrupt as e:
        logger.info('Keyboard interrupt.')
    except SystemExit as _:
        logger.info('System exit.')
    except Exception as e:
        logger.info(get_exception_msg(e))
        sys.exit(1)
    finally:
        logger.info('Cleanup')
        server.stop()
        backend.destroy()
    sys.exit(0)
Example #2
0
 def __init__(self, sponsor_string, first_test_date, username, password):
     self.sponsor_string = sponsor_string
     self.first_test_date = first_test_date
     self.username = username
     self.password = password
     self.simple_name = self.getSimpleNameFromEmail()
     self.servers = [
         Server(self.sponsor_string, server_id)
         for server_id in self.getServerIDs()
     ]
     logger = logging.getLogger("pyspeed.SpeedtestSponsor.init")
     logger.info("sponsor instantiated")
Example #3
0
def spool_up(doJoin):
    if doJoin:
        connectTo = input("Enter address (address:port): ")        
        if connectTo == "":
            connectTo = "2.tcp.ngrok.io:14583"
        host = connectTo.split(":")[0]
        port = connectTo.split(":")[1]
        print(host)
        print(port)
        myclient = Client(host, int(port))#change to whatever ngrok tunnels to
        client = threading.Thread(target=myclient.start, args=())
        client.start()
        client.join()
    myserver = Server("localhost", 8000)
    server = threading.Thread(target=myserver.start, args=())
    server.start()
    server.join()
Example #4
0
from select import select
from sys import exit, argv
from socket import socket, AF_INET, SOCK_STREAM
from modules.server import Server
from modules.aescipher import AESCipher
from modules.utils import notify
from modules.keystore import KeyStore
from modules.gfx import Gfx
from conf import gfx
from time import sleep
import threading

server_address = ("0.0.0.0", 9000)
if len(argv) == 3:
    server_address = (argv[1], int(argv[2]))
serv = Server(server_address)

def handle_sockets(readable, writable, exceptional, serv):
    stop = serv.handle_readable(readable)
    serv.handle_writable(writable)
    return stop, serv.inputs, serv.outputs

def start_server():
    stop = False
    notify("AESchat Server Running on port %s:%i" %(server_address))
    while stop is not True:
        readable, writable, exceptional = select(serv.inputs, serv.outputs, serv.inputs)
        stop, serv.inputs, serv.outputs = handle_sockets(readable, writable, exceptional, serv)
    print("\nGoodbye")
    serv.socket.close()
    return 0
Example #5
0
def run_server():
    server = Server(conf)
    asyncio.run(server.start())
Example #6
0
from modules.utils import load_conf
from modules.server import Server

parser = argparse.ArgumentParser()
parser.add_argument("--loglevel",
                    "-l",
                    type=str,
                    default="ERROR",
                    help="The log level (default: ERROR)")
parser.add_argument("--logfile",
                    "-f",
                    type=str,
                    help="The path to logfile (default: None)")

if __name__ == "__main__":
    args = parser.parse_args()
    loglevel = args.loglevel
    logfile = args.logfile

    logging.basicConfig(filename=logfile,
                        level=loglevel,
                        format="%(asctime)s - %(message)s")

    conf = load_conf()
    server = Server(conf)

    try:
        asyncio.run(server.start())
    except KeyboardInterrupt:
        logging.info("Server is shut down by KeyboardInterrupt")
Example #7
0
import sys

from modules.server import Server
from modules.client import Client

if __name__ == "__main__":
    HOST = sys.argv[2] if len(sys.argv) == 3 else "localhost"
    if sys.argv[1] == 's':
        Server(local_host=HOST)
    elif sys.argv[1] == 'c':
        Client(remote_host=HOST)
    else:
        print("Provide CLA")
Example #8
0
    def __init__(self):
        super().__init__('main.log', 'main.pid', 'config.yml')

        server = Server(self.config['servconf'], self.config['dbconf'],
                        self.config['uniconf'], self.config['goipconf'])
        server.start()