Exemplo n.º 1
0
def test_create_join():
    idA, handle, A = yield from core.client()
    idB, handle, B = yield from core.client()
    clan = core.rndstr()
    yield from core.send(A, "clan.create", clan, "Test")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.create"
    assert rs["args"][0] == True
    clan_id = rs["args"][1]
    yield from core.send(B, "clan.join", clan_id)
    rs = yield from core.recv(B)
    assert rs["name"] == "clan.join"
    assert rs["args"][0] == True
    yield from core.send(A, "clan.members")
    rs = yield from core.recv(A)
    members = {i[0]:i for i in rs["args"][0]["members"]}
    assert idB in members
    assert members[idB][2] == "Pending"
    assert members[idB][3] == False
    yield from core.send(A, "clan.setmembertype", idB, "Member")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.setmembertype"
    assert rs["args"][0] == idB
    assert rs["args"][1] == "Member"
    assert rs["args"][2] == True
    yield from core.send(B, "clan.members")
    rs = yield from core.recv(B)
    members = {i[0]:i for i in rs["args"][0]["members"]}
    assert idB in members
    assert members[idB][2] == "Member", members
Exemplo n.º 2
0
def test_list():
    id, handle, A = yield from core.client()
    clan = core.rndstr()
    yield from core.send(A, "clan.create", clan, "Test")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.create"
    assert rs["args"][0] == True
    yield from core.send(A, "clan.list")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.list"
    assert type(rs["args"][0]) == type([])
Exemplo n.º 3
0
def get_dest_and_send(data) :

	try :

		dest = raw_input('Enter the user you wish to send to : ')
		core.send(users.local_user, users.remote_users[dest.strip()], data)
		
		print 'Message sent'

	except KeyError, e :
		print  e.message + ' is not in your list of users'
		get_dest_and_send(data)	
Exemplo n.º 4
0
def test_authenticate_falure():
    ws = yield from core.conn()
    assert ws is not None
    obj = yield from core.recv(ws)
    handle = core.rndstr()
    email = core.rndstr()
    passwd = core.rndstr()
    yield from core.send(ws, "auth.register", handle, email, passwd)
    msg = yield from core.recv(ws)
    yield from core.send(ws, "auth.authenticate", email, passwd)
    msg = yield from core.recv(ws)
    assert msg["name"] == "auth.authenticate"
    assert msg["args"][0] == False
Exemplo n.º 5
0
def send(message, destination, tag=0, comm=core.MPI_COMM_WORLD):
    """
    mpi.send( message, destination[, tag(defaults to 0), comm(default is mpi.COMM_WORLD)]))
    
    Sends message to destination with tag (default tag is 0).
    """
    messageType = getMessageType( message )
    core.send( messageType, 1, core.MPI_INT, destination, tag, comm )
    if messageType == SINGLE: #single elements (integers, characters)
        print "Single Element Case:"
        dataType = getSingleType( message )
        core.send( dataType, 1, core.MPI_INT, destination, tag+1, comm )
        returnvalue = core.send( message, 1, dataType, destination, tag+2, comm )
    elif messageType == SEQUENCE: #non-array sequences
        print "Sequence Case:"
        dataType = getSequenceType( message )
        dataType = int(core.send( dataType, 1, core.MPI_INT, destination, tag+1, comm ))
        length = int(core.send( len(message), 1, core.MPI_INT, destination,tag+2, comm))
        returnvalue = core.send(  message, length, dataType, destination, tag+3, comm )
    elif messageType == ARRAY:
        print "Array Case:"
        returnvalue = array.send(message, destination, tag+1, comm )
    else: #object case
        print "Generic Object Case:"
        returnvalue = sobj.send( message, destinaion, tag+1, comm )# (2) are the same
    return returnvalue
Exemplo n.º 6
0
def test_authenticate_success():
    ws = yield from core.conn()
    assert ws is not None
    msg = yield from core.recv(ws)
    uid = msg["args"][0]

    handle = core.rndstr()
    email = core.rndstr()
    passwd = hashlib.sha256(core.rndstr().encode("utf8")).hexdigest()

    yield from core.send(ws, "auth.register", handle, email, passwd)
    msg = yield from core.recv(ws)
    digest = hashlib.sha256((uid+passwd).encode("utf8")).hexdigest()
    yield from core.send(ws, "auth.authenticate", email, digest)
    msg = yield from core.recv(ws)
    assert msg["name"] == "auth.authenticate"
    assert msg["args"][0] == True
Exemplo n.º 7
0
def test_register():
    ws = yield from core.conn()
    assert ws is not None
    obj = yield from core.recv(ws)
    assert obj["name"] == "welcome"
    assert obj["args"][0] is not None
    handle = core.rndstr()
    email = core.rndstr()
    passwd = core.rndstr()
    yield from core.send(ws, "auth.register", handle, email, passwd)
    msg = yield from core.recv(ws)
    assert msg["name"] == "auth.register"
    assert msg["args"][0] == True
    yield from core.send(ws, "auth.register", handle, email, passwd)
    msg = yield from core.recv(ws)
    assert msg["name"] == "auth.register"
    assert msg["args"][0] == False
Exemplo n.º 8
0
def isend( array, destination, tag, communicator ):
    datatype = getMpiType(array)
    size = nm.size( array )
    shape = nm.shape( array )
    rank = nm.rank( array )
    request = core.isend( datatype, 1, core.MPI_INT, destination, tag, communicator )
    request = core.isend( rank, 1, core.MPI_INT, destination, tag+1, communicator )
    request = core.isend( shape, rank, core.MPI_INT, destination, tag+2, communicator )
    request = core.isend( size, 1, core.MPI_INT, destination, tag+3, communicator )
    return core.send( array, size, datatype, destination, tag+4, communicator )
Exemplo n.º 9
0
def send( array, destination, tag, communicator ):
    """
    Specialized array send:

    array.send( myarray, destination, tag, communicator )

    example:
      import mpi
      mpi.array.send( Numeric.ones(100,Numeric.Int32), 0, 7, mpi.MPI_COMM_WORLD )
    """
    datatype = getMpiType(array)
    size = nm.size( array )
    shape = nm.shape( array )
    rank = nm.rank( array )
    
    core.send( datatype, 1, core.MPI_INT, destination, tag, communicator )
    core.send( rank, 1, core.MPI_INT, destination, tag+1, communicator )
    core.send( shape, rank, core.MPI_INT, destination, tag+2, communicator )
    core.send( size, 1, core.MPI_INT, destination, tag+3, communicator )
    return core.send( array, size, datatype, destination, tag+4, communicator )
Exemplo n.º 10
0
def send(message, destination, tag=0, comm=core.MPI_COMM_WORLD):
    """
    comm.send( message, destination[, tag(defaults to 0)])
    
    Sends message to destination with tag (default tag is 0).
    
    This method will serialize message and send it as an array of characters.
    This method trades efficency for generality: i.e. It takes extra time and bandwidth
    to serialize and transmit the serialized object.  However, any Python object
    that can be Pickled can be sent.
    
v    Currently this method uses the python pickle module(rather then cPickle).
    """
    s = pickle.dumps( message )
    errorcode = core.send( s, len(s), core.MPI_CHAR, destination, tag, comm )
    return None    
Exemplo n.º 11
0
from core import run, send
import os
from datetime import date
from secrets import VACANCY_LIST

now = date.today()
dir_name = './' + str(now.day) + str(now.strftime("%b")) + '/'
filename_tail = "_" + str(now.day) + "_" + str(now.month) + "_new_vacancies.txt"
i = 0
files = []
file_all = ""

for vacancy in VACANCY_LIST:
    run(vacancy)
    vacancy_split = "_".join(vacancy.split())
    fl = open(dir_name + f'{vacancy_split}' + f'{filename_tail}', 'r', encoding='utf-8' )
    files.append(fl.read())
    file_all += (vacancy.upper() + " VACANCIES:\n\n")* bool(files[i]) + files[i] * bool(files[i])
    fl.close()
    i += 1

if file_all == "":
    print("Nothing to send")
else:  
    file_name = dir_name + "all" + f"{filename_tail}"
    f_all = open(f"{file_name}", "w+", encoding="utf-8" )
    f_all.write(file_all)
    f_all.close()
    send(file_name)