def __init__(self): obj = socket.socket() obj.connect((self.comm.getClientConf("server", "host"), int(self.comm.getClientConf("server", "port")))) ret_bytes = obj.recv(self.CONST.BUFFSIZE) ret_str = self.comm.tanslate(str(ret_bytes)) print(ret_str) while True: inp = raw_input(self.comm.tanslate("你好请问您有什么问题? \n >>>")) if inp == "q": inp = cryptofactory.CryptoFactory().encrypto( inp, self.comm.getClientConf("transmission", "crypto_key")) data = self.comm.createPacket(inp, 0) obj.sendall(bytes(data)) break elif inp == "upload": upload.Upload(obj) else: inp = cryptofactory.CryptoFactory().encrypto( inp, self.comm.getClientConf("transmission", "crypto_key")) data = self.comm.createPacket(inp, 99999, "text") obj.sendall(bytes(data)) ret_bytes = obj.recv(self.CONST.BUFFSIZE) ret_str = self.comm.tanslate(str(ret_bytes)) print(ret_str + "112233")
def main(): settings.init() settings.logger = log.Log(settings.log_file_name) settings.logger.daemon = True settings.logger.start() settings.logger.log('Starting NewsGrabber') tools.create_dir(settings.dir_new_urllists) tools.create_dir(settings.dir_old_urllists) tools.create_dir(settings.dir_donefiles) tools.create_dir(settings.dir_ready) tools.create_dir(settings.dir_last_upload) tools.create_dir(settings.dir_dumped_url_data) if not os.path.isfile(settings.targets): settings.logger.log( "Please add one or more rsync targets to file '{settings.targets}'" .format(**locals()), 'ERROR') settings.irc_bot = irc.IRC() settings.irc_bot.daemon = True settings.irc_bot.start() time.sleep(30) settings.upload = upload.Upload() settings.upload.daemon = True settings.upload.start() settings.run_services = service.RunServices() settings.run_services.daemon = True settings.run_services.start() while settings.running: time.sleep(1)
def Analyse(fileName): img = cv2.imread('./images/' + fileName) cv2.imwrite("./images/red_comp_" + fileName, img[:, :, 2]) y = img[:, :, 2].mean(axis=0) xAxis = [i for i in range(len(y))] plt.plot(xAxis, y) plt.xlabel("width of Image in pixels") plt.ylabel("Average of Red component along the columns") plt.title("Average of Red component v/s pixel density") plt.savefig("./images/hist-" + fileName) upload.Upload(filePath="./images/hist-" + fileName, filename="hist-" + fileName, topic="agricert/hist") upload.Upload(filePath="./images/red_comp_" + fileName, filename="red_comp_" + fileName, topic="agricert/red_comp")
def parseData(self, dev): if self.is_verbose: print('Device %s is %s, rssi: %d dBm, connectable: %s.' % (dev.addr, dev.addrType, dev.rssi, dev.connectable)) # 1 - flags, 2 - Incomplete 16b Services, 255 - Manufacturer, 22 - 16b Service Data, 9 - Complete Local Name SERVICE_DATA = 22 # [1d18828809e4070310112302] for (adtype, desc, value) in dev.getScanData(): if adtype == SERVICE_DATA and value.startswith('1d18'): raw_data = bytes.fromhex(value[4:]) if raw_data == self.last_raw_data: if self.is_verbose: print("skip duplicate data") return is_stabilized = (raw_data[0] & (1 << 5)) != 0 is_weight_removed = (raw_data[0] & (1 << 7)) != 0 self.last_raw_data = raw_data if is_stabilized is True and is_weight_removed is False: weight = int.from_bytes(raw_data[1:3], byteorder='little') / 100 if (raw_data[0] & (1 << 1)) != 0: # kg weight /= 2 # catty to kg print(weight) # output: 74.7 if float(os.environ['lower']) <= weight <= float( os.environ['upper']): weight_upload = upload.Upload() weight_upload.upload_weight(weight)
def capture(fileName): global msg if camera._camera_exception == None and msg != "disconnected": camera.capture("./images/" + fileName) upload.Upload(filePath="./images/" + fileName, filename=fileName, topic="agricert/image/uploadStatus") else: pubsub.publish("agricert/pingBack", "disconnected")
def main(): try: if conf.source == "directory": albums = directory.get_photos() elif conf.source == "iPhoto" or conf.source == "Aperture": albums = iphoto.get_photos() u = upload.Upload() u.upload(albums) except Exception as e: logger.error(e, exc_info=True) sys.exit(1)
def main(): settings.init() settings.logger = log.Log(settings.log_file_name) settings.logger.daemon = True settings.logger.start() settings.logger.log( 'Starting grabber {name}'.format(name=settings.irc_nick)) tools.create_dir(settings.dir_ready) tools.create_dir(settings.dir_new_lists) tools.create_dir(settings.dir_old_lists) if not os.path.isfile(settings.target_main): raise Exception( "Please add a rsync target to file '{settings.target_main}'.". format(**locals())) settings.irc_bot = irc.IRC() settings.irc_bot.daemon = True settings.irc_bot.start() time.sleep(30) settings.upload = upload.Upload() settings.upload.daemon = True settings.upload.start() settings.grab = grab.Grab() settings.grab.daemon = True settings.grab.start() while settings.running: # if not settings.logger.isAlive(): # print('The logger stopped running...') # settings.irc_bot.send('PRIVMSG', 'The logger stopped running...', # settings.irc_channel_bot) # settings.running = False # if not settings.irc_bot.isAlive(): # print('The IRC bot stopped running...') # settings.running = False # if not settings.upload.isAlive(): # print('The uploader stopped running...') # settings.irc_bot.send('PRIVMSG', 'The uploader stopped running...', # settings.irc_channel_bot) # settings.running = False # if not settings.grab.isAlive(): # print('The grabber stopped running...') # settings.irc_bot.send('PRIVMSG', 'The grabber stopped working...', # settings.irc_channel_bot) # settings.running = False time.sleep(1)
def main(): if os.path.isfile('UPDATE'): os.remove('UPDATE') # settings.init() settings.logger = log.Log(settings.log_file_name) settings.logger.daemon = True settings.logger.start() settings.logger.log('Starting NewsGrabber') tools.create_dir(settings.dir_new_urllists) tools.create_dir(settings.dir_old_urllists) tools.create_dir(settings.dir_donefiles) tools.create_dir(settings.dir_ready) tools.create_dir(settings.dir_last_upload) tools.create_dir(settings.dir_dumped_url_data) if not os.path.isfile(settings.targets): settings.logger.log("Please add one or more rsync targets to file " \ "'{targets}'".format(targets=settings.targets), 'ERROR') if not os.path.isfile(settings.keys): settings.logger.log("Please add you keys by running 'add_keys.py'.", 'ERROR') settings.irc_bot = irc.IRC() settings.irc_bot.daemon = True settings.irc_bot.start() time.sleep(30) settings.upload = upload.Upload() settings.upload.daemon = True settings.upload.start() settings.run_services = service.RunServices() settings.run_services.daemon = True settings.run_services.start() while settings.running: if os.path.isfile('STOP'): os.remove('STOP') open('UPDATE', 'w').close() break time.sleep(1)
def main(): if os.path.isfile('UPDATE'): os.remove('UPDATE') settings.init() settings.logger = log.Log(settings.log_file_name) settings.logger.daemon = True settings.logger.start() settings.logger.log( 'Starting grabber {name}'.format(name=settings.irc_nick)) tools.create_dir(settings.dir_ready) tools.create_dir(settings.dir_new_lists) tools.create_dir(settings.dir_old_lists) if not os.path.isfile(settings.target_main): raise Exception( "Please add a rsync target to file '{target_main}'.".format( target_main=settings.target_main)) settings.irc_bot = irc.IRC() settings.irc_bot.daemon = True settings.irc_bot.start() time.sleep(30) settings.upload = upload.Upload() settings.upload.daemon = True settings.upload.start() settings.grab = grab.Grab() settings.grab.daemon = True settings.grab.start() while settings.running: if os.path.isfile('STOP'): os.remove('STOP') open('UPDATE', 'w').close() break time.sleep(1)
def post(self, user_id): # TODO: Filename de la video à gerer if error.ifId(user_id) is False: return error.notFound() token_head = include.header() if error.ifToken(token_head) is True: id_user = include.get_user_id_by_token(token_head) """ user_id is received as str, so we need to cast it in int """ if id_user != int(user_id): return error.forbidden() parser = reqparse.RequestParser() parser.add_argument('name', type=str, help='name of the video') parser.add_argument('source', type=str, help='file of the video') args = parser.parse_args() uploader = upload.Upload() _name = args['name'] _source = uploader.upload_file() header = {'Authorization':token_head} # Got the response from the encoder by rabbit rabb = rabbitSender.SenderClient() response = rabb.call(_source) if _name and _source is not None and _name and _source is not "": new_video = mod.Video(_name, 300, id_user, _source, 0, 1) mod.db.session.add(new_video) mod.db.session.commit() result = video_schema.dump(new_video).data # Setting all paths to video_format tmp_path = _source.split('.')[0] output_path = '' probe = ffmpeg.probe(_source) height = 0 definition = [1080, 720, 480, 360, 240] for metadata in probe['streams']: for (key, value) in metadata.items(): if key == "height": height = value logging.info("\n\nprinting source :: {} \t P {}\n\n".format(tmp_path, _source)) startIndex = 0 #Récupère l'index de départ par rapport à la vidéo input for i in range(len(definition)): if definition[i] == height: startIndex = i break for value in range(startIndex, len(definition)): file_format = str(definition[value]) output_path = tmp_path+"_"+file_format+'p.mp4' logging.info("PRINTING OUTPUT FILE :: {}\t FILE FORMAT :: {} \n\n".format(output_path, file_format)) # Redirect to the patch route to encode video patch_response = requests.patch("http://localhost:5000/video/{}".format(result['id']), data = {'file':output_path, 'format':file_format}, headers=header) if patch_response.status_code != 201: return error.badRequest(10010, "Something went wrong") return make_response(jsonify({'Message': 'OK', 'data': result}), 201) else: return error.badRequest(10001, "Veuillez remplir tous les champs obligatoire!") else: return error.unauthorized()
def uploadchannels_button_update(self): self.close() upload.Upload()
def __init__(self): self.evt = event.Event() self.motion = motion.Motion() #sencor class self.shoot = shoot.Shoot() #actuator class self.upload = upload.Upload() #actuator class self.led = led.led()