Example #1
0
def sign_out():

    #Check if user is logged in
    try:
        username = cherrypy.session['username']
        hashed_pw = cherrypy.session['password']

        thread.stop()

        #Call API to log off
        r = urllib2.urlopen(
            "http://cs302.pythonanywhere.com/logoff?username="******"&password="******"&enc=0")
        response = r.read()

        #Successful log off
        if (response[0] == '0'):
            cherrypy.lib.sessions.expire()
            raise cherrypy.HTTPRedirect('/')

        #Error logging off
        else:
            raise cherrypy.HTTPRedirect('/')

    #If user isn't logged in, this method redirects user to main page
    except KeyError:
        raise cherrypy.HTTPRedirect('/')
def kill_it_all(signum, frame):
    for thread in threads_to_kill:
        logging.warning("killing all threads")
        thread.stop()
    pubsub.close()
    logging.shutdown()
    sys.exit()
 def stop(self, _id):
     LOG.debug("Stopping all PolicyThreads %s" % self.policy_threads[_id])
     for thread in self.policy_threads[_id]:
         LOG.debug("Stopping PolicyThread %s" % thread)
         thread.stop()
     LOG.debug("Stopped all PolicyThreads %s" % self.policy_threads[_id])
     LOG.debug("Stopping CheckerThread: %s" % self.checker_threads[_id])
     #self.checker_threads[_id].stop()
     LOG.debug("Stopped CheckerThread %s" % self.checker_threads[_id])
Example #4
0
 def stop(self, _id):
     LOG.debug("Stopping all PolicyThreads %s" %
               self.policy_threads[_id])
     for thread in self.policy_threads[_id]:
         LOG.debug("Stopping PolicyThread %s" % thread)
         thread.stop()
     LOG.debug("Stopped all PolicyThreads %s" %
               self.policy_threads[_id])
     LOG.debug("Stopping CheckerThread: %s" % self.checker_threads[_id])
     #self.checker_threads[_id].stop()
     LOG.debug("Stopped CheckerThread %s" % self.checker_threads[_id])
Example #5
0
def _xray_frame_process(queue, linger=True, wait=None):
    """The _xray_frame_process() function starts the viewer in a
  separate thread.  It then continuously reads data from @p queue and
  dispatches update events to the viewer.  The function returns when
  it reads a @c None object from @p queue or when the viewer thread
  has exited.
  """

    from Queue import Empty
    import rstbx.viewer

    # Start the viewer's main loop in its own thread, and get the
    # interface for sending updates to the frame.
    thread = _XrayFrameThread()
    send_data = thread.send_data

    while True:
        try:
            payload = queue.get(timeout=1)

            if payload is None:
                if linger:
                    thread.join()
                else:
                    thread.stop()
                return

            if not thread.isAlive():
                thread.join()
                return

            if wait is not None:
                time.sleep(wait)

            # All kinds of exceptions--not just PyDeadObjectError--may occur
            # if the viewer process exits during this call.  XXX This may be
            # dangerous!
            try:
                send_data(rstbx.viewer.image(payload[0]), payload[1])
            except Exception:
                pass
        except Empty:
            pass
Example #6
0
def _xray_frame_process(queue, linger=True, wait=None):
  """The _xray_frame_process() function starts the viewer in a
  separate thread.  It then continuously reads data from @p queue and
  dispatches update events to the viewer.  The function returns when
  it reads a @c None object from @p queue or when the viewer thread
  has exited.
  """

  from Queue import Empty
  import rstbx.viewer

  # Start the viewer's main loop in its own thread, and get the
  # interface for sending updates to the frame.
  thread = _XrayFrameThread()
  send_data = thread.send_data

  while True:
    try:
      payload = queue.get(timeout=1)

      if payload is None:
        if linger:
          thread.join()
        else:
          thread.stop()
        return

      if not thread.isAlive():
        thread.join()
        return

      if wait is not None:
        time.sleep(wait)

      # All kinds of exceptions--not just PyDeadObjectError--may occur
      # if the viewer process exits during this call.  XXX This may be
      # dangerous!
      try:
        send_data(rstbx.viewer.image(payload[0]), payload[1])
      except Exception:
        pass
    except Empty:
      pass
Example #7
0
    def ConnectVM(self, p_id, vm):
        key = vm.name
        try:
            vmtype = vms_dict[key]
            Type = vmtype['vmtype']
        except:
            Type = "UNKNOWN"
        Logger.info("VM is a %s type", Type)

        if Type == 'JSP' or Type == 'UNKNOWN':
            dlg = ProgressDialog.ProgressDialog(self, u'连接服务器...')
            thread = Console.LaunchThread(p_id, vm, Type, dlg)
            thread.start()
            if dlg.ShowModal() == wx.ID_CANCEL:
                thread.stop()
            else:
                thread.join()
        elif Type == 'RDP':
            RDP = RDPLoginDialog.RDPLoginDialog(vm, Type)
            RDP.ShowModal()
def __videoFeed(threadName, dely, drone):
    '''Starts video feed from the drone'''
    if drone == None:
        printRed("[Error] Drone not initialized")

    drone.sdVideo()
    drone.frontCam()
    CDC = drone.ConfigDataCount
    while CDC == drone.ConfigDataCount:
        time.sleep(0.0001)

    drone.videoFPS(10)
    drone.startVideo()

    cv2.namedWindow( "Display");

    imcount = drone.VideoImageCount
    time_tmp = time.time()
    while True:
        try:
            # wait for next frame
            while imcount == drone.VideoImageCount:
                time.sleep(0.01)
            imcount = drone.VideoImageCount

            t_now = time.time()
            t_diff = t_now - time_tmp
            time_tmp = t_now
            fps = (1 / t_diff) if t_diff > 0 else 0

            mat = drone.VideoImage;

            cv2.rectangle(mat,(180, 30), (0, 0), (0,0,0), -1)
            cv2.putText(mat,'{: <2} FPS'.format(fps),(10,20), cv2.FONT_HERSHEY_SIMPLEX, 0.5,(255,255,255),2)
            cv2.imshow("Display", mat)
            cv2.waitKey(1)
        except KeyboardInterrupt:
            # die silently
            thread.stop()
			cl = ""
			for i in localApps:
				cl = cl + i[0] + ", "
			if not (msg == 'Mouse' or msg == 'Media' or msg == 'Gaming'):
				n.update(msg+" Controller Started", "You can now connect from your device", "/etc/control/icon.png")
				n.set_urgency(pn.URGENCY_LOW)
				n.set_timeout(-1)
				n.show()
	def stop(self):
		s.close()
        	self._stop.set()

lthread = localThread()
lthread.start()
#Start the blutooth
bs=bt.BluetoothSocket( bt.RFCOMM )
bs.bind(("",bt.PORT_ANY))
bs.listen(1)
port = bs.getsockname()[1]
uuid = "0003"
bt.advertise_service( bs, "ControlServerLinux", service_id = uuid, service_classes = [ uuid, bt.SERIAL_PORT_CLASS ], profiles = [ bt.SERIAL_PORT_PROFILE ])
print("Now listing")

while True: # Main server loop
	(cs, info) = bs.accept() #cs = cient socket
	print("Accepted connection from "+str(info)+" with the content:")
	thread.start_new_thread(connection, (cs,0))

bs.close() #Close the socket
thread.stop()
Example #10
0
def exit_handler(signal, frame):
    print 'You pressed Ctrl+C!'
    for thread in threads:
        thread.stop()
Example #11
0
def exit_handler(signal, frame):
        print 'You pressed Ctrl+C!'
        for thread in threads:        
            thread.stop()
Example #12
0
def kill_thread_refresh_price_monitor(tl_monitor, thread):
    """tue la mise a jour des prix du monitor lorsque l on ferme la toplevel"""
    thread.stop()
    tl_monitor.destroy()