Exemplo n.º 1
0
	def test_disconnect_ports(self):
		engine = self.fixture1()
		port = Connector(engine, "proc1", kind=Port, direction=Out, name="OutPort1")
		port2 = Connector(engine, "proc2", kind=Port, direction=In, name="Inport2")
		port.disconnect(port2)
		listPeers = [ connector.name for connector in port.peers ]
		self.assertEqual([], listPeers)
Exemplo n.º 2
0
	def test_disconnect_controls(self):
		engine = self.fixture1()
		control = Connector(engine, "proc1", kind=Control, direction=Out, name="OutControl1")
		control2 = Connector(engine, "proc2", kind=Control, direction=In, name="Incontrol2")
		control.disconnect(control2)
		listPeers = [ connector.name for connector in control.peers ]
		self.assertEqual([], listPeers)
Exemplo n.º 3
0
	def test_connectTwoPortsWithSameDirectionAndFail(self) :
		engine = self.fixture1()
		port = Connector(engine, "proc1", kind=Port, direction=Out, name="OutPort1")
		port2 = Connector(engine, "proc2", kind=Port, direction=Out, name="Outport1")
		try:
			port.connect(port2)
		except SameConnectorDirection, e:
			self.assertEquals("Unable to connect: proc1.OutPort1 and proc2.Outport1 have the same direction", e.message)
Exemplo n.º 4
0
	def	test_connectPortWithControlAndFail(self) :
		engine = self.fixture1()
		port = Connector(engine, "proc1", kind=Port, direction=Out, name="OutPort1")
		port2 = Connector(engine, "proc2", kind=Control, direction=In, name="Incontrol1")
		try:
			port.connect(port2)
		except DifferentConnectorKind, e:
			self.assertEqual(e.message,
				"Unable to connect: "
				"proc1.OutPort1 and proc2.Incontrol1 "
				"are different kinds of connectors")
Exemplo n.º 5
0
 def doRegister(self):
     user = self.user_entry.text()
     pas = self.pass_entry.text()
     first = self.fname_entry.text()
     last = self.lname_entry.text()
     mail = self.email_entry.text()
     phone = self.phone_entry.text()
     data = {'username': user, 'password': pas, 'first_name': first,
             'last_name': last, 'email': mail, 'phone': phone}
     url = "Somchai/register"
     connector = Connector()
     connector.post(url, data)
Exemplo n.º 6
0
	def	test_connectControlWithDifferentTypeControlAndFail(self) :
		engine = self.fixture1()
		port = Connector(engine, "proc1", kind=Control, direction=Out, name="OutControl1")
		port2 = Connector(engine, "proc2", kind=Control, direction=In, name="Incontrol3")
		try:
			port.connect(port2)
			self.fail("Exception expected")
		except DifferentConnectorType, e:
			self.assertEqual(e.message,
				"Unable to connect: "
				"proc1.OutControl1 and proc2.Incontrol3 "
				"handle different data types")
Exemplo n.º 7
0
	def test_connectTwoPortsPassingInportFirst(self) :
		engine = self.fixture1()
		port = Connector(engine, "proc1", kind=Port, direction=Out, name="OutPort1")
		port2 = Connector(engine, "proc2", kind=Port, direction=In, name="Inport1")
		port.connect(port2)
		self.assertMultiLineEqual(
			self.peerList(port),
			"proc2.Inport2\n"
			"proc2.Inport1\n"
			)
		self.assertMultiLineEqual(
			self.peerList(port2),
			"proc1.OutPort1\n"
			)
Exemplo n.º 8
0
 def __init__(self, hostip, backlog=1, port=10070, buff_size=1024):
     self.HOSTIP = hostip
     self.PORT = port
     self.BUFF_SIZE = buff_size
     self.BACKLOG = backlog
     self.socket = None
     self.connector = Connector()
Exemplo n.º 9
0
	def test_disconnectallcontrol_peers(self) :
		engine = self.empty()
		engine.addProcessing("DummyControlSource", "source")
		engine.addProcessing("DummyControlSink", "sink")
		engine.addProcessing("DummyControlSink", "sink2")
		source = Connector(engine, "source", "Control", "Out", "OutControl1")
		sink = Connector(engine, "sink", "Control", "In", "InControl1")
		sink2 = Connector(engine, "sink2", "Control", "In", "InControl1")
		source > sink
		source > sink2
		self.assertMultiLineEqual(
			self.peerList(source),
			"sink.InControl1\n"
			"sink2.InControl1\n"
			)
		source.disconnect()
		self.assertMultiLineEqual(self.peerList(source), "")
Exemplo n.º 10
0
	def test_disconnectallport_peers(self) :
		engine = self.empty()
		engine.addProcessing("DummyPortSource", "source")
		engine.addProcessing("DummyPortSink", "sink")
		engine.addProcessing("DummyPortSink", "sink2")
		source = Connector(engine, "source", "Port", "Out", "OutPort1")
		sink = Connector(engine, "sink", "Port", "In", "InPort1")
		sink2 = Connector(engine, "sink2", "Port", "In", "InPort1")
		source > sink
		source > sink2
		self.assertMultiLineEqual(
			self.peerList(source),
			"sink.InPort1\n"
			"sink2.InPort1\n"
			)
		source.disconnect()
		self.assertMultiLineEqual(self.peerList(source), "")
	def __setupTracking__(self):
		
		#get mocap interface
		self.mocap = Connector.getMocapInterface()

		#Get the shutter-glass rigid body
		self.shutterGlass = self.mocap.returnPointerToRigid(Connector.SHUTTERGLASSES)
		self.head_tracker = viz.link(self.shutterGlass.vizNode,viz.NullLinkable,srcFlag=viz.ABS_PARENT)
		self.cave.setTracker(self.head_tracker)

		# Create cave view
		cave_origin = vizcave.CaveView(self.head_tracker)
		
		#In case you want to override & translate the physical location of cave, uncommnet this
		
		'''
		origin_tracker = viztracker.KeyboardMouse6DOF()
		origin_link = viz.link(origin_tracker, cave_origin)
		origin_link.setMask(viz.LINK_POS)
		'''
		
		#Foot rigidBodies
		leftFootRigid = self.mocap.returnPointerToRigid(Connector.L_FOOT)
		rightFootRigid = self.mocap.returnPointerToRigid(Connector.R_FOOT)
		
		#Foot visuals, make them 100% transparent when not in debug mode
		self.leftFootViz = vizshape.addBox(size=(.2,.2,.2))
		self.rightFootViz = vizshape.addBox(size=(.2,.2,.2))
		
		if(self.debug):
			self.leftFootViz.alpha(0.025)
			self.rightFootViz.alpha(0.025)
		else:
			self.leftFootViz.alpha(0.0075)
			self.rightFootViz.alpha(0.0075)
		
		#Foot class objects
		self.leftFoot = Foot(mocapFootObj = leftFootRigid, name="Left")
		self.rightFoot = Foot(mocapFootObj = rightFootRigid, name="Right")
		
		#setup buffer updates
		vizact.onupdate(0, self.leftFoot.populateNextBufferElement)
		vizact.onupdate(0, self.rightFoot.populateNextBufferElement)
		vizact.onupdate(0, self.updateBooties)
		viz.callback(viz.COLLIDE_BEGIN_EVENT, self.collideDetected)
Exemplo n.º 12
0
 def test_disconnect_inverseOrder(self):
     engine = self.empty()
     engine.addProcessing("DummyControlSource", "source")
     engine.addProcessing("DummyControlSink", "sink")
     engine.addProcessing("DummyControlSink", "sink2")
     source = Connector(engine, "source", "Control", "Out", "OutControl1")
     sink = Connector(engine, "sink", "Control", "In", "InControl1")
     sink2 = Connector(engine, "sink2", "Control", "In", "InControl1")
     source > sink
     source > sink2
     self.assertMultiLineEqual(self.peerList(source), "sink.InControl1\n"
                               "sink2.InControl1\n")
     sink.disconnect(source)
     self.assertMultiLineEqual(self.peerList(source), "sink2.InControl1\n")
Exemplo n.º 13
0
 def test_disconnectallport_peers(self):
     engine = self.empty()
     engine.addProcessing("DummyPortSource", "source")
     engine.addProcessing("DummyPortSink", "sink")
     engine.addProcessing("DummyPortSink", "sink2")
     source = Connector(engine, "source", "Port", "Out", "OutPort1")
     sink = Connector(engine, "sink", "Port", "In", "InPort1")
     sink2 = Connector(engine, "sink2", "Port", "In", "InPort1")
     source > sink
     source > sink2
     self.assertMultiLineEqual(self.peerList(source), "sink.InPort1\n"
                               "sink2.InPort1\n")
     source.disconnect()
     self.assertMultiLineEqual(self.peerList(source), "")
Exemplo n.º 14
0
def accept_data(server, LOG: Log, expected_client=None):
    """ Waits for a data connection
    """
    server.listen(2)
    attempts = 0
    while attempts < 3:
        try:
            (client, (client_host, _x)) = server.accept()
            if expected_client is not None:
                if client_host != expected_client:
                    raise Exception(
                        "Rejecting connection from unexpected host %s - expected %s"
                        % (client_host, expected_client))
            return Connector.Connector(client,
                                       LOG,
                                       conntype="DATA",
                                       binary_mode=True)
        except EnvironmentError as e:
            LOG.error(e)
            attempts += 1
 def __init__(self, parent=None):
     if VentanaPrincipal.__instance != None:
         raise Exception("This class is a singleton!")
     else:
         QtGui.QWidget.__init__(self, parent)
         self.ui = Ui_MainWindow()
         self.ui.setupUi(self)
         #conector
         self.connector = c.Connector(ssh_servidor="126.0.0.2",
                                      ssh_usuario="http",
                                      ssh_clave="pendejo01",
                                      ssh_puerto=22)
         self.subNet = self.connector.consultarSubRedes()
         for net in self.subNet:
             self.ui.net_selector.addItem(net["ip"])
             self.ui.net_selector_2.addItem(net["ip"])
         #salida
         QtCore.QObject.connect(self.ui.net_search,
                                QtCore.SIGNAL("clicked()"), self.search_net)
         QtCore.QObject.connect(self.ui.net_search_2,
                                QtCore.SIGNAL("clicked()"),
                                self.search_net2)
Exemplo n.º 16
0
def EyeDetection(account):
    global MY_IP, MY_PORT
    sleep = False
    counter = 0

    # AWS Public Key
    con = Connector.Connector(ip=MY_IP,
                              port=MY_PORT,
                              method=Connector.CONNECTED_TCP)
    print("Connected to " + MY_IP + ':' + str(MY_PORT))

    try:
        print("start")
        eye = det.Eye(
            cascade_path=
            "./opencv/haarcascades/haarcascade_eye_tree_eyeglasses.xml")
        for frame in eye.getFrame():
            eye.analyze(frame)

            percent = float(eye.sleepPercentage())

            if percent > 0.8: counter += 1
            else: counter = 0

            if counter > 15:
                sleep = True
                # This statement just test statement
            elif counter == 0:
                sleep = False

            if DataProcessing(con, sleep, account) == -1:
                return -1

    except KeyboardInterrupt:
        print("end")
        return 0
Exemplo n.º 17
0
class Serversocket:
    def __init__(self, hostip, backlog=1, port=10070, buff_size=1024):
        self.HOSTIP = hostip
        self.PORT = port
        self.BUFF_SIZE = buff_size
        self.BACKLOG = backlog
        self.socket = None
        self.connector = Connector()

    def open_socket(self):
        try:
            self.socket = socket.socket()
            self.socket.bind((self.HOSTIP, self.PORT))
            self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            self.socket.listen(self.BACKLOG)
        except socket.error:
            if self.socket:
                self.socket.close()
            # Exception Handeling missing
            print("Cant open Socked")

    def run_server(self):
        self.open_socket()

        while True:
            try:
                connection, client = self.socket.accept()
                data = connection.recv(self.BUFF_SIZE)
                if data:
                    if self.connector.feedData(data) == "end":
                        connection.close()
                        break
            except Exception:
                # Exception Handeling missing
                print("Something Went wrong with accepting a Client")
                continue
Exemplo n.º 18
0
def remove_user(event, session_api, chat_id, msg_command, dict_of_users):
    if Connector.isAdmin(chat_id, event.object.message['from_id']):
        getConversationMembers(session_api, event, dict_of_users)
        # check forward messages
        if len(event.object.message['fwd_messages']) != 0:
            for temp in event.object.message['fwd_messages']:
                Messages.remove_user(chat_id, int(temp['from_id']))

        # check id in msg_command
        try:
            msg_ids = msg_command.split()[1:]
            for user_idd in msg_ids:
                user_id = (str(user_idd[3:]).split('|'))[0]
                if int(user_id) in dict_of_users.keys():
                    Messages.remove_user(chat_id, user_id)
                else:
                    Messages.send_message(
                        session_api, chat_id, 'User with id: \'' +
                        str(user_id) + '\' is not in chat!')
        except ValueError:
            Messages.send_message(session_api, chat_id, 'Id is incorrect!')
    else:
        Messages.send_message(session_api, chat_id,
                              'Permission denied! You is not admin!')
Exemplo n.º 19
0
# - blankCells (array) -
# test pierce points XRAY
# cas surface 2D avec body en BAR
import Converter as C
import Connector as X
import Generator as G
import Geom as D
import Transform as T
import KCore.test as test

surf = D.circle((0, 0, 0), 0.5, 0., 360.)
surf = C.convertArray2Tetra(surf)
res = [surf]

a = G.cart((-1., -1., 0.), (0.1, 0.1, 1.), (20, 20, 1))
ca = C.array('cellN', 19, 19, 1)
ca = C.initVars(ca, 'cellN', 1.)
blankingTypes = [-1, -2, 1, 2]
deltas = [0., 0.1]
dim = 2
isNot = [0, 1]
c = 1
for delta in deltas:
    for masknot in isNot:
        for type in blankingTypes:
            celln = X.blankCells([a], [ca], [surf], type, delta, dim, masknot)
            test.testA(celln, c)
            c += 1
Exemplo n.º 20
0
# - getIntersectingDomainsAABB (array) -
import Generator as G
import Converter as C
import Connector as X

a = G.cart((0., 0, 0), (1, 1, 1), (10, 10, 10))
b = G.cart((9., 0, 0), (1, 1, 1), (10, 10, 10))

bb = G.BB([a, b])
ret = X.getIntersectingDomainsAABB(bb)
print ret
Exemplo n.º 21
0
# - eikonal (array) -
import Dist2Walls
import Generator as G
import Converter as C
import Geom as D
import Connector as X
import KCore.test as test

# Bloc cartesien
N = 512
N = 128
h = 2./N
a = G.cart((-1.,-1.,-1.),(h,h,h),(N,N,N))
cellN = C.initVars(a, 'cellN=1')
cellN = C.extractVars(cellN, ['cellN'])

# Init wall
sphere = D.sphere((0.,0.,0.), 0.1, 30)
sphere = C.convertArray2Tetra(sphere)
sphere = G.close(sphere)
cellN = X.blankCellsTri([a], [cellN], [sphere], blankingType=0)

a = C.addVars([a, cellN[0]])
a = C.initVars(a,'speed=%f'%(1./h))
a = C.initVars(a, 'Phi=1.e12*({cellN}>0.)')

# Eikonal
b = Dist2Walls.eikonal(a)
test.testA([b],1)
Exemplo n.º 22
0
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''
import Connector

import MainCL

__author__ = "Pedro Tarroso"
__copyright__ = "2012, Pedro Tarroso"
__credits__ = "Contributors: Silvia Carvalho\
                 Jose Carlos Brito"

__license__ = "GPL"
__version__ = "1.1"

#Create Connector
conn = Connector.connection()

#Check if there are arguments (Command line or GUI)
if MainCL.startGUI:
    import MainGUI
    GUI = MainGUI.EMNN(conn)
    GUI.startgui()
else:
    MainCL.startCL(conn)
            port = arg
        if opt == '--selectAllFrom':
            select_table = arg
            select = True
        if opt == '--query':
            query = arg
            rq = True
    """
    print "psql user    ", str(psql_user)
    print "psql pass    ", str(psql_pass)
    print "psql host    ", str(psql_host)
    print "psql port    ", str(psql_port)
    print "psql database    ", str(database)
    print "query    ", str(query)
    print "select from table    ", str(select_table)
    """

    #m20Connector = M20PSQLConnector('data_reply_db', 'dario', 'localhost', 'password')
    #m20Connector = M20PSQLConnector('postgres', 'cloudera-scm', 'localhost', '7432', 'y6jOvCiNAz')
    #connector = Connector('postgres', psql_user, 'localhost', '7432', psql_pass)
    connector = Connector(database, psql_user, psql_host, psql_port, psql_pass)
    connector.connect()

    if (rq):
        connector.showQuery(query)

    if (select):
        connector.printAll(select_table)

    connector.close()
Exemplo n.º 24
0
	
	kml = ('<Placemark>\n'
	       '<name> %s </name>\n'
	       '<Point>\n'
	       '<coordinates>%6f,%6f</coordinates>\n'
               '</Point>\n'
	       '</Placemark>\n'
		)%(ip,longt,latt)
	return (kml)
	    		

kmlheader = '<?xml version="1.0" encoding="UTF-8"?>\n<kml xmlns="http://www.opengis.net/kml/2.2">\n<Document>\n'
kmlfooter= '</Document>\n</kml>\n'


IP,PCAP= Connector.connect("Connector6.ini")

if PCAP!="ND":
	
	f= open(PCAP)
	pcap = dpkt.pcap.Reader(f)
	printpcap(pcap)
else:

	printrecord(IP) 
	#ip,longt,lat = printrecord(IP)
        #kmlpt = retkml(ip,longt,lat)
	#kmldoc=kmlheader+kmlpt+kmlfooter
	#with open ("Onedesti.kml","w") as f:
        #    f.write(kmldoc)
Exemplo n.º 25
0
def create_session(connector: Connector, config, LOG: Log, ftp_server,
                   cmd_server):
    try:
        LOG.debug("Processing %s" % connector.info())
        job = Protocol.establish_connection(connector, config)
        if job is False:
            connector.close()
            return
        if job is None:
            connector.write_message(
                "530 Not logged in: no matching transfer request found")
            connector.close()
            return
        if not config['DISABLE_IP_CHECK']:
            client_ips = job['client-ip'].split(",")
            peer = connector.client_ip()
            verified = False
            for client_ip in client_ips:
                if client_ip == peer:
                    verified = True
                    break
            if not verified:
                raise Exception(
                    "Rejecting connection for '%s' from %s, allowed: %s" %
                    (job['user'], peer, str(client_ips)))
        LOG.info("Established %s for '%s'" % (connector.info(), job['user']))
    except Exception as e:
        connector.write_message("500 Error establishing connection: %s" %
                                str(e))
        connector.close()
        return

    limit = config['MAX_CONNECTIONS']
    user = job['user']
    user_job_counts = config['_JOB_COUNTER']
    counter = user_job_counts.get(user)
    with job['_LOCK']:
        if len(job['_PIDS']) > 0:
            num = counter.increment()
            if num > limit:
                counter.decrement()
                connector.write_message(
                    "500 Too many active transfer requests / sessions for '%s' - server limit is %s"
                    % (user, limit))
                connector.close()
                return
    pid = os.fork()
    if pid:
        # parent
        connector.cleanup()
        LOG.debug("Created new UFTP session for '%s', child process <%s>" %
                  (user, pid))
        with job['_LOCK']:
            job['_PIDS'].append(pid)
        return

    #
    # child - cleanup, drop privileges and launch session processing
    #
    try:
        LOG.reinit()
        ftp_server.close()
        cmd_server.close()
        user = job['user']
        groups = job.get('group')
        user_switch_status = BecomeUser.become_user(user, groups, config, LOG)
        if user_switch_status is not True:
            connector.write_message("530 Not logged in: %s" %
                                    user_switch_status)
            raise Exception("Cannot switch UID/GID: %s" % user_switch_status)
        connector.write_message("230 Login successful")
        job['UFTP_NOWRITE'] = config["UFTP_NOWRITE"]
        job['MAX_STREAMS'] = config['MAX_STREAMS']
        job['compress'] = job.get("compress", "false").lower() == "true"
        job['PORTRANGE'] = config.get("PORTRANGE", (0, -1, -1))
        job['SERVER_HOST'] = config['SERVER_HOST']
        job['ADVERTISE_HOST'] = config.get("ADVERTISE_HOST", None)
        session = Session.Session(connector, job, LOG)
        session.run()
        connector.close()
    except Exception as e:
        LOG.error(e)
    os._exit(0)
Exemplo n.º 26
0
# - connectMatch (array) -
import Generator as G
import Connector as X
import Geom as D
import Transform as T
import Converter as C
# 3D raccord i = 1 partiel profil NACA 
msh = D.naca(12., 5001)
msh2 = D.line((1.,0.,0.),(2.,0.,0.),5001); msh = T.join(msh, msh2)
msh2 = D.line((2.,0.,0.),(1.,0.,0.),5001); msh = T.join(msh2, msh)
Ni = 300; Nj = 50
distrib = G.cart((0,0,0), (1./(Ni-1), 0.5/(Nj-1),1), (Ni,Nj,1))
naca = G.hyper2D(msh, distrib, "C")
res = X.connectMatch(naca,naca,sameZone=1,dim=2)
C.convertArrays2File([naca],"out.plt")
print(res)
# - blankCellsTri (array) - 'NODE IN'
import Converter as C
import Connector as X
import Generator as G
import Geom as D
import Post as P
import KCore.test as test
import Transform as T

# Tet mask
m = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 10))
m = P.exteriorFaces(m)
m = T.reorder(m, (-1, ))
m = C.convertArray2Tetra(m)
# Mesh to blank
a = G.cart((-5., -5., -5.), (0.5, 0.5, 0.5), (100, 100, 100))
# celln init
ca = C.array('cellN', 100, 100, 100)
ca = C.initVars(ca, 'cellN', 1.)
# Blanking
celln = X.blankCellsTri([a], [ca],
                        m,
                        blankingType=0,
                        tol=1.e-12,
                        cellnval=4,
                        overwrite=1)
celln = C.addVars([[a], celln])
#C.convertArrays2File(celln, 'out0.plt')
test.testA(celln, 1)
Exemplo n.º 28
0
# - maskXRay (array) -
import Converter as C
import Connector as X
import Geom as D
import Transform as T

surf = D.sphere((0, 0, 0), 0.5, 20)
surf = T.rotate(surf, (0., 0., 0.), (0., 1., 0.), 90.)
res = X.maskXRay__([surf])
C.convertArrays2File([res], "out.plt")
# - blankCellsTetra (array) - 'NODE IN'
import Converter as C
import Connector as X
import Generator as G
import Geom as D
import KCore.test as test
import sys

# Test 1
# Tet mask
mT4 = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 10))
mT4 = C.convertArray2Tetra(mT4)
# Mesh to blank
a = G.cart((-5., -5., -5.), (0.5, 0.5, 0.5), (100, 100, 100))
# celln init
ca = C.array('cellN', 100, 100, 100)
ca = C.initVars(ca, 'cellN', 1.)
# Blanking
celln = X.blankCellsTetra([a], [ca], mT4, blankingType=0, tol=1.e-12)
celln = C.addVars([[a], celln])
#C.convertArrays2File(celln, 'out0.plt')
test.testA(celln, 1)
# - setHoleInterpolatedPts (array) -
import Converter as C
import Connector as X
import Generator as G
import KCore.test as test
def sphere(x,y,z):
    if x*x+y*y+z*z < 0.5**2 : return 0.
    else: return 1.
    
# Cas HEXA: champ cellN en noeud
a = G.cartHexa((-2.,-1.,-1.),(0.1,0.1,0.1), (21,21,21))
a = C.initVars(a,'cellN', sphere, ['x','y','z'])
nod = 1
for d in [-2,-1,0,1,2,5]:
    celln = X.setHoleInterpolatedPoints(a, depth=d)
    test.testA([celln], nod); nod+=1
#
# Champ en centres
#
a = G.cartHexa((-2.,-1.,-1.),(0.1,0.1,0.1), (21,21,21))
ac = C.node2Center(a)
ac = C.initVars(ac, 'cellN', sphere, ['x','y','z'])
for d in [-2,-1,0,1,2,5]:
    celln = X.setHoleInterpolatedPoints(ac, depth=d)
    test.testA([celln], nod); nod+=1
# - setDoublyDefinedBC (array) -
import Converter as C
import Connector as X
import Generator as G

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
b = G.cart((2.5, 2.5, -2.5), (0.5, 0.5, 0.5), (10, 10, 30))
celln = C.array('cellN', a[2] - 1, a[3] - 1, a[4] - 1)
celln = C.initVars(celln, 'cellN', 1)
indmax = celln[2] * celln[3]
celln[1][0][0:indmax] = 2
cellnb = C.array('cellN', b[2] - 1, b[3] - 1, b[4] - 1)
cellnb = C.initVars(cellnb, 'cellN', 1)
celln = X.setDoublyDefinedBC(a,
                             celln, [b], [cellnb], [1, a[2], 1, a[3], 1, 1],
                             depth=1)
ac = C.node2Center(a)
ac = C.addVars([ac, celln])
C.convertArrays2File([ac], 'out.plt')
Exemplo n.º 32
0
         #print r1.status, r1.reason
         #print resp
         if invalidmsg not  in resp: # and ivnalidmsg2 not in resp:
	         print "[+] password found ! : " + str(password)
                 found = True
		 retpass=password
         else:
                 print '[-] password tested : '+str(password)

	 nbr -=1
		 


headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

site,page,params,userfield,passfield,user,invalidmsg,passfile,nbrthread=Connector.connect('ConnectorA30.ini')


p = subprocess.Popen(['pwd'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out, err = p.communicate()
print out


nbrthread=int(nbrthread)

#params = "username=ousdfdf&password=azerty"
#site='licence.efficientprotection.com'
#page = "/login"
#ivnalidmsg = "/login"
#ivnalidmsg=""
#passfield="password" 
# - connectMatch 3D (array) -
import Generator as G
import Connector as X
import KCore.test as test
import Transform as T
import Converter as C

a = G.cart((0.,0.,0.), (0.1, 0.1, 0.1), (11, 21, 2))
ca = C.array('cellN',10,20,1)
ca = C.initVars(ca, 'cellN', 1.)
a = C.addVars(a, 'cellN')

# partiellement coincident
a2 = G.cart((1., 0.5, 0.), (0.1, 0.1, 0.1), (11, 21, 2))
ca2 = C.array('cellN',10,20,1)
ca2 = C.initVars(ca2, 'cellN', 1.)
a2 = C.addVars(a2, 'cellN')
res = X.connectMatch(a, a2)
test.testO(res,1)
#
# coincident
a3 = G.cart((1., 0., 0.), (0.1, 0.1, 0.1), (11, 21, 2))
res = X.connectMatch(a, a3)
test.testO(res,2)

# raccord 1 sur 2
a3 = T.oneovern(a3,(2,2,1))
res = X.connectMatch(a, a3)
test.testO(res,3)
# - optimizeOverlap (array) -
import Converter as C
import Generator as G
import Transform as T
import Connector as X
import KCore.test as test

Ni = 50
Nj = 50
Nk = 2
a = G.cart((0, 0, 0), (1. / (Ni - 1), 1. / (Nj - 1), 1), (Ni, Nj, Nk))
b = G.cart((0, 0, 0), (2. / (Ni - 1), 2. / (Nj - 1), 1), (Ni, Nj, Nk))
a = T.rotate(a, (0, 0, 0), (0, 0, 1), 10.)
a = T.translate(a, (0.5, 0.5, 0))

ca = C.node2Center(a)
ca = C.initVars(ca, 'cellN', 1.)
cb = C.node2Center(b)
cb = C.initVars(cb, 'cellN', 1.)
# critere de volume
res = X.optimizeOverlap(a, ca, b, cb)
test.testA(res, 1)
# priorites
res = X.optimizeOverlap(a, ca, b, cb, prio1=0, prio2=0)
test.testA(res, 2)
Exemplo n.º 35
0
# extrusion vers l exterieur : pas d intersection des facettes
#-------------------------------------------------------------
d = C.array('d', 5, 1, 1)
for i in range(1, d[2] + 1):
    d[1][0, i - 1] = 0.01 * i
# structure
s = D.sphere6((0, 0, 0), 1., N=10)
A = []
Ac = []
for i in xrange(len(s)):
    a = G.addNormalLayers(s[i], d)
    ac = C.node2Center(a)
    ac = C.initVars(ac, 'cellN', 1)
    Ac.append(ac)
    A.append(a)
res = X.blankIntersectingCells(A, Ac, tol=1.e-8)
test.testA(res, 1)

# non structure hexa
sh = C.convertArray2Hexa(s)
A = []
Ac = []
for i in xrange(len(sh)):
    a = G.addNormalLayers(sh[i], d)
    ac = C.node2Center(a)
    ac = C.initVars(ac, 'cellN', 1)
    Ac.append(ac)
    A.append(a)
res = X.blankIntersectingCells(A, Ac, tol=1.e-8)
test.testA(res, 2)
Exemplo n.º 36
0
      found = True

  except Exception, e:
     if 'read_nonblocking' in str(e):
       Fails += 1
       time.sleep(5)
       connect(host, user, password, False)
     elif 'synchronize with original prompt' in str(e):
       time.sleep(1)
       connect(host, user, password, False) 
  finally:

	if release: 
		connection_lock.release()

host,user,passwdFile=Connector.connect('ConnectorA12.ini')

fn =open(passwdFile, 'r')
for line in fn.readlines():
  if found:
	print "[*] exit : password found"
  	exit(0)
  if fails>5:
	print "[!] exit : too many socket Timeouts"
	exit(0)
  connection_lock.acquire()
  password = line.strip('\r').strip('\n')
  print "[>] Testing : "+str(password)
  t = Thread(target=connect, args=(host,user,password,True))
  child = t.start()
Exemplo n.º 37
0
# - maskXRay (array) -
import KCore.test as test
import Connector as X
import Generator as G
import Geom as D
import Transform as T
import Converter as C

# cas sphere 3D
surf = D.sphere((0, 0, 0), 0.5, 20)
surf = T.rotate(surf, (0., 0., 0.), (0., 1., 0.), 90.)
surf = C.convertArray2Tetra(surf)
res0 = X.maskXRay__([surf])
test.testA([res0], 1)

# cas surface 2D avec body en BAR
surf = D.circle((0, 0, 0), 0.5, 0., 360.)
surf = C.convertArray2Tetra(surf)
res0 = X.maskXRay__([surf], 0., 2)
test.testA([res0], 2)

# cas surface 2D avec body en TRI
surf = G.cylinder((0., 0., 0.), 0., 1., 360., 0., 1., (50, 50, 2))
surf = T.subzone(surf, (1, 50, 1), (50, 50, 2))
surf = C.convertArray2Tetra(surf)
res0 = X.maskXRay__([surf], 0., 2)
test.testA([res0], 3)
Exemplo n.º 38
0
from pymavlink import mavutil
from pynput import keyboard
from dronekit import connect, VehicleMode
import dronekit_sitl
import numpy as np
from colorama import Fore, Back, Style
from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM
import sys
import Connector
import DroneControl
import DroneCommands

SPEED = 3  # Speed in m/s
ALTITUDE = 4  # ALtitude in meters

connector = Connector.Connector()
vehicle = connector.connect()
control = DroneControl.DroneControl(vehicle)
drone = DroneCommands.DroneCommands(vehicle, SPEED, ALTITUDE)

print tabulate([['t', 'takeoff'], ['w', 'go forward'], ['s', 'go backward'], ['a', 'go left'], ['d', 'go right']
                   , ['r', 'rotate right'], ['e', 'rotate left'], ['i', 'go up'], ['k', 'go down'], ['esc', "land"]
                   , ['backspace', 'go home'], ['m(n)', 'altitude above ground(sea level)'], ['b', 'athimut']],
               headers=['button', 'action'])


def on_press(key):
    try:
        k = key.char  # single-char keys
    except:
        k = key.name  # other keys
Exemplo n.º 39
0
# - blankCellsTri (array) - 'NODE IN'
import Converter as C
import Connector as X
import Generator as G
import Geom as D
import Post as P


# Test 1
# Tet mask
m = G.cart((0.,0.,0.), (0.1,0.1,0.2), (10,10,10))
m = P.exteriorFaces(m)
m = C.convertArray2Tetra(m)
# Mesh to blank
a = G.cart((-5.,-5.,-5.), (0.5,0.5,0.5), (100,100,100))
# celln init
ca = C.array('cellN',100,100,100)
ca = C.initVars(ca, 'cellN', 1.)
# Blanking
celln = X.blankCellsTri([a], [ca], m, blankingType=0, tol=1.e-12)
celln = C.addVars([[a], celln])
C.convertArrays2File(celln, 'out0.plt')




Exemplo n.º 40
0
def admin_list(chat_id, session_api):
    message = Connector.db_adminlist(chat_id)
    Messages.send_message(session_api, chat_id, message)
Exemplo n.º 41
0
from select import select
import Connector

ssh_port = 5022
http_port = 5080

servers = []
clients = []
ssh2http = Connector.new_connector('ssh', 'http')
ssh2http.bind(ssh_port)
ssh2http.listen(100)

http2ssh = Connector.new_connector('http', 'ssh')
http2ssh.bind(http_port)
http2ssh.listen(100)

servers.append(http2ssh)
servers.append(ssh2http)
while servers:
    rlist, _, _ = select(servers + clients, [], [])

    for sock in rlist:
        if sock in servers:
            clients.append(sock.accept())
        else:
            buff = sock.recv()
            print sock
            print buff
Exemplo n.º 42
0
s = T.addkplane(s)

# Grille cartesienne (reguliere)
BB = G.bbox([s])
ni = 100; nj = 100; nk = 3
xmin = BB[0]; ymin = BB[1]; zmin = BB[2]-0.5
xmax = BB[3]; ymax = BB[4]; zmax = BB[5]+0.5
hi = (xmax-xmin)/(ni-1); hj = (ymax-ymin)/(nj-1)
h = min(hi, hj)
ni = int((xmax-xmin)/h)+7; nj = int((ymax-ymin)/h)+7
b = G.cart( (xmin-3*h, ymin-3*h, zmin), (h, h, 1.), (ni,nj,nk) )
celln = C.array('cellN', ni, nj, nk)
celln = C.initVars(celln, 'cellN', 1.)

# Masquage
cellno = X.blankCells([b], [celln], [s], blankingType=0, delta=0., dim=2) 
a = C.initVars(s, 'cellN', 1)
b = C.addVars([b, cellno[0]])

# Adapte le front de la grille a la surface
b = T.subzone(b, (1,1,2), (b[2],b[3],2))
f = G.snapFront(b, [s])

test.testA([f], 1)

# Adapte le front de la grille a la surface avec optimisation du front
f = G.snapFront(b, [s], optimized = 1)

test.testA([f], 11)

# Grille non structuree
Exemplo n.º 43
0
import sys
import Connector

a,b = Connector.connect("ConnectorA31.ini")

print a + b
Exemplo n.º 44
0
# - maximizeBlankedCells (array) 2D-
import Converter as C
import Connector as X
import Generator as G
import KCore.test as test


def F(x, y):
    if (x + y < 1): return 1
    else: return 2


Ni = 50
Nj = 50
a = G.cart((0, 0, 0), (1. / (Ni - 1), 1. / (Nj - 1), 1), (Ni, Nj, 1))
a = C.addVars(a, 'cellN')
a = C.initVars(a, 'cellN', F, ['x', 'y'])

a1 = X.maximizeBlankedCells(a, 2, dir=0)
test.testA([a1], 1)

a2 = X.maximizeBlankedCells(a, 1, dir=0)
test.testA([a2], 2)
Exemplo n.º 45
0
class Processor:
    def __init__(self):
        print("Face processs")
        self.config = get_config
        self.face = face_recognize(
            self.config(net_mode='ir_se', threshold=1.22, detect_id=1))
        self.queue = []
        self.queue_tem = []
        self.max_pro = 4
        self.connector = Connector("Face")
        self.sound = "sound"

        self.threshold_distance = self.config().threshold_distance
        try:
            self.labels, self.features = self.connector.get_users()
            self.features = np.array(self.features)
            self.features = self.features.reshape(self.features.shape[0], 512)
        except:
            self.features = np.array([]).reshape(0, 512)
            self.labels = []
        print(self.features.shape)

    def identify(self, features):
        if (len(self.features) == 0):
            return ["Unknown"] * len(features)
        res = []
        features = np.array(features)
        features = np.expand_dims(features, 1)
        diff = self.features - features
        dist = np.sum(np.power(diff, 2), axis=2)
        minimum = np.amin(dist, axis=1)
        min_idx = np.argmin(dist, axis=1)
        result = []
        for id, (min, min_id) in enumerate(zip(minimum, min_idx)):
            if min < self.threshold_distance:
                # confidence = self.confidence(features[id].reshape(512,), self.features[min_id])
                p_id = self.labels[min_id]
                res.append(p_id)
            else:
                res.append("Unknown")
        return res

    def get_feature(self, image):
        features, boxes = self.face.feature_img(image)
        if (len(features) == 1):
            return features[0]

        return []

    def process_add_user(self, image, name, year, phone):

        feature = self.get_feature(image)
        if (feature != []):
            self.connector.add_user(name, year, phone, feature)
            self.labels.append(name)
            self.features = np.concatenate(
                (self.features, feature.reshape(1, 512)))
            try:
                if (not path.isfile(os.path.join(self.sound, name + ".mp3"))):
                    tts = gTTS(text=name, lang='vi')
                    filename = os.path.join(self.sound, name + ".mp3")
                    tts.save(filename)
                playsound.playsound(os.path.join(self.sound, "them" + ".mp3"))
                playsound.playsound(os.path.join(self.sound, name + ".mp3"))

            except Exception as e:
                print(e)

            print("add success ful ", name)
        else:
            print("fail length ", len(feature))

    def process_attend(self, image):
        # t1=time.time()
        features, boxes = self.face.feature_img(image)
        # print("time1 ",time.time()-t1)
        if (features.shape[0] != 0):
            names = self.identify(features)
            for x in names:
                if (x != "Unknown"):
                    #visualize with sound
                    if (self.connector.check_recent(x)):
                        try:
                            if (not path.isfile(
                                    os.path.join(self.sound, x + ".mp3"))):
                                tts = gTTS(text=x, lang='vi')
                                filename = os.path.join(self.sound, x + ".mp3")
                                tts.save(filename)
                            playsound.playsound(
                                os.path.join(self.sound, "xin_chao" + ".mp3"))
                            playsound.playsound(
                                os.path.join(self.sound, x + ".mp3"))
                        except Exception as e:
                            print(e)

                    #add database
                    self.connector.add_attend(x)

    def add_process(self, data, mode):
        # print(mode)
        if (mode == "add"):
            self.queue_tem.append(
                threading.Thread(target=self.process_add_user,
                                 args=(
                                     data[0],
                                     data[1],
                                     data[2],
                                     data[3],
                                 )))
        if (mode == "attend"):
            self.queue_tem.append(
                threading.Thread(target=self.process_attend, args=(data[0], )))

    def process_queue(self):
        while 1:
            # print("yes")
            n = len(self.queue)
            if (n > 0 or len(self.queue_tem) > 0):

                for i in range(n - 1, max(n - self.max_pro - 1, -1), -1):
                    self.queue[i].start()
                    self.queue[i].join()
                    del self.queue[i]
                    time.sleep(1)
                for i in range(len(self.queue_tem) - 1, -1, -1):
                    self.queue.append(self.queue_tem[i])
                    del self.queue_tem[i]
            else:
                time.sleep(1)
Exemplo n.º 46
0
a = D.sphere((0, 0, 0), 1, 5)
a = C.convertArray2Tetra(a)

# Grille cartesienne
ni = 10
nj = 10
nk = 10
hi = 2.2 / (ni - 1)
hj = 2.2 / (nj - 1)
hk = 2.2 / (nk - 1)
b = G.cart((-1. - 0.1, -1. - 0.1, -1. - 0.1), (hi, hj, hk), (ni, nj, nk))
celln = C.array('cellN', ni, nj, nk)
celln = C.initVars(celln, 'cellN', 1.)

# Masquage
cellno = X.blankCells([b], [celln], [a], blankingType=0, delta=1.e-10, dim=3)
a = C.initVars(a, 'cellN', 1)
b = C.addVars([b, cellno[0]])

# Selection du front
b1 = P.selectCells2(b, cellno[0])
bext = P.exteriorFaces(b1)
bexts = T.splitConnexity(bext)
f = bexts[1]
f = C.initVars(f, 'cellN', 1)

# Lissage du front
f = T.smooth(f, eps=0.5, niter=5)  # lissage du front quad
#C.convertArrays2File([f], 'out.plt')

# Creation du maillage
import threading
import time
import Connector as connector
import Metamodel as meta
import os
from pynput.keyboard import Controller, Key

if __name__ == "__main__":

    aim = connector.Connexion()
    aim.simulate()
    aim.interrupt()
Exemplo n.º 48
0
from Crypto.PublicKey import RSA
from Crypto import Random
import pickle
import socket
import sys
import Connector

###########################

#random_generator = Random.new().read
#key = RSA.generate(1024,random_generator)

host,port,k1,k2=Connector.connect('ConnectorA29.ini')

port= int(port)
key_public = RSA.importKey(open(k1,"rb").read())
key= RSA.importKey(open(k2,"rb").read())
client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

try: 
	
	client.connect((host,port))
except Exception,e:

	print str(e)
	sys.exit(0)
	
if port==22:
	client.recv(1024)
	
cmd = "GetN"