-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
81 lines (66 loc) · 2.26 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# /usr/bin/env python 2.7
# -*- coding: utf-8 -*-
import cPickle as pickle
import threading
import socket
from abc import ABCMeta, abstractmethod
from deco.decorator import requiere
import pdb
class connection(object):
def __init__(self):
global socketconn
host = ('127.0.0.1', 9994)
socketconn = socket.socket()
socketconn.connect(host)
class Person(object):
__metaclass__ = ABCMeta
name = str
last_name = str
age = int
sex = str
status = str
identification = str
@abstractmethod
@requiere(str, str, int, str, str)
def __init__(self, name, last_name, age, sex, identification):
self.name = name
self.last_name = last_name
self.age = age
self.sex = sex
self.identification = identification
# Register(self)
# pickle.HIGHEST_PROTOCOL = -1
stringobj = pickle.dumps(self, -1)
global socketconn
socketconn.send(stringobj)
print socketconn.recv(1024)
class Student(Person):
@requiere(str, str, int, str, str)
def __init__(self, name, last_name, age, sex, identification):
self.status = 'student' # token for student
# Call the super class, then execute the constructor with the respective data
super(Student, self).__init__(name, last_name, age, sex, identification)
class Teacher(Person):
@requiere(str, str, int, str, str)
def __init__(self, name, last_name, age, sex, identification):
self.status = 'teacher' # token for teacher
super(Teacher, self).__init__(name, last_name, age, sex, identification)
class simple_query(object):
def __init__(self, attr):
self.attr = attr
self.result = self.getdata()
def getdata(self):
global socketconn
socketconn.send(self.attr)
stringobj = socketconn.recv(1024)
return pickle.loads(stringobj)
if __name__ == "__main__":
print 'client'
connection()
Student('maria', 'soaaex', 2, 'famale', '1225689')
Teacher('Joseeeeaa', 'Boleor', 4, 'Famale', '236991')
pdb.set_trace()
socketconn.close()
#Student('jose', 'Boleor', 4, 'Male', '5536991')
#Student('Joseeeeaa', 'Boleor', 4, 'Famale', '236991')
#Student('jose', 'Boleor', 4, 'Male', '78777777777777')