示例#1
0
def process_text(Input):
    global settings, log
    if 'how are you' in Input:
        log('COMMAND : HOW ARE YOU')
        speak('I am fine. You?')
        Input = ''
    elif 'clear log' in Input:
        log("COMMAND : CLEAR LOG")
        commmands.clear_log(settings)
        Input = ''
    elif 'update' in Input:
        commands.update()
        Input = ''
    elif 'search' or 'google' in Input:
        commands.google(Input)
        Input = ''
    elif ' push install' in Input:
        log('SUDO UPDATE')
        commands.update_install()
        Input = ''
    elif 'edit' or 'open' in Input:
        log("COMMAND : EDIT")
        commands.edit(Input, settings)
        Input = ''
    else:
        speak('Sorry, I don\'t know what you\'re talking about.')
    Input = ''
示例#2
0
def handle_command(command, options, parser):
    if command == 'create':
        create(options, parser)
    if command == 'update':
        update(options, parser)
    if command == 'find':
        find(options, parser)
    if command == 'mo':
        mo(options, parser)
示例#3
0
def main():

    if contains_confgit_command(): # if user has specified confgit command

        args = vars(parse_confgit_args())

        if args['debug']:
            debug_mode = True

        print_debug(args)

        if args['command'] == 'init':
            init(args['init_path'], args['CONFIG_PATH'])

        config = load_config(args['CONFIG_PATH'])
        print_debug(config)

        if args['command'] == 'include':
            for i in args['paths']:
                include(i, config, args['CONFIG_PATH'])

        if args['command'] == 'exclude':
            for i in args['paths']:
                exclude(i, config, args["CONFIG_PATH"])

        if args['command'] == 'sync':
            sync(config)

        if args['command'] == 'update':
            update(config)

        if args['command'] == 'backup':
            backup(config, args['backup_path'])

    else: # if user has not specified confgit command
        #! doesn't check if it's a valid git command, could be problem later - g3ner1c
        config, git_command = parse_git_args()
        print_debug(git_command)
        cd(config["repo_dir"])
        send_to_git(git_command)
示例#4
0
文件: oj.py 项目: andyjjrt/oj
import argparse

from commands import login, update, submit, get

parser = argparse.ArgumentParser(
    prog="oj",
    description="CLI tool that helping you access CP Online Judge",
)
subcmd = parser.add_subparsers(dest='subcmd', help='methods', metavar='options')
subcmd.required = True

login_parser = subcmd.add_parser('login', help='Login to your oj accont')
update_parser = subcmd.add_parser('update', help='Update your contest and problem list')
submit_parser = subcmd.add_parser('submit', help='submit your hw code')
submit_parser.add_argument("assign_no", type=str, help="assignment number")
submit_parser.add_argument("file", type=str, help="code file")
get_parser = subcmd.add_parser('get', help='Get your assign sample code')
get_parser.add_argument("assign_no", type=str, help="assignment number")


args = parser.parse_args()
if args.subcmd == "login":
    login()
elif args.subcmd == "update":
    update()
elif args.subcmd == "submit":
    submit(args.assign_no, args.file)
elif args.subcmd == "get":
    get(args.assign_no)
示例#5
0
    logfile = 'flight-' + d.strftime("%Y-%m-%d-%H:%M:%S") + '.log'
    try:
        f = open(logfile, 'wb')
    except:
        print "Cannot open:", logfile
        quit()
    return f
  
if args.serial:
    try:
        ser = serial.Serial(args.serial, args.baud, timeout=dt)
    except:
        print "Cannot open:", args.serial
        import serial.tools.list_ports
        ports = list(serial.tools.list_ports.comports())
        print "Available ports:"
        for p in ports:
            print p
        quit()

    f = new_logfile()
        
    while True:
        auraparser.serial_read(ser, f)
        current.compute_derived_data()
        commands.update(ser)
        telnet.update()
        httpserver.update()
else:
    print "A serial port must be provided"    
示例#6
0
argparser.add_argument('--telnet-port', default=5050, help='telnet port')
argparser.add_argument('--http-port', default=8888, help='http/ws port')
argparser.add_argument('--html-root', default='.')

args = argparser.parse_args()

dt = 1.0 / float(args.hertz)

telnet.init(args.telnet_port)
httpserver.init(args.http_port, args.html_root)

try:
    ser = serial.Serial(args.serial, args.baud, timeout=dt)
    auraparser.init()
except:
    print "Cannot open:", args.serial
    import serial.tools.list_ports
    ports = list(serial.tools.list_ports.comports())
    print "Available ports:"
    for p in ports:
        print p
    quit()

while True:
    auraparser.update(ser)
    current.compute_derived_data()
    requests.gen_requests()
    commands.update(ser)
    telnet.update()
    httpserver.update()
示例#7
0
def main(argv):
    devices = adb.get_attached_devices()

    print """
    !!! Test AntiVirus !!!
    !!! Attenzione:    !!!
    !!! Prima dell'installazione dell'agente, al dispositivo va impedito il libero accesso ad internet. !!!
    """
    print """ prerequisiti:
    1) Telefono connesso in USB,
    2) USB Debugging enabled (settings/developer options/usb debugging)
    3) NESSUNA SIM INSTALLATA <======== NB!!!!!!!!!!!!!!!!!!!!!!!
    4) screen time 2m (settings/display/sleep)
    """

    print "devices connessi:"
    for device in devices:
        print device

    if not devices:
        print "non ci sono device connessi"
    else:

        if len(devices) > 1:
            dev = raw_input("su quale device si vuole eseguire il test? ")
            print "Eseguo il test su %s" % dev

        if len(sys.argv) >= 2:
            serialno = sys.argv[1]

        else:
            serialno = '.*'

        device = AdbClient(serialno=serialno)
        # print 'Args=', (str(sys.argv))
        # operation = sys.argv[1]

        init = raw_input('Init everything? (y/n)')
        if init == "y":
            print "Init!"
            commands.init_device(device.serialno)

        dev = device.serialno

        operation = -1

        while operation != "99":
            print ''
            print '#################       OPERATIONS      #################'
            print 'What operation do you want to perform?'
            print '1  - get new configuration from installed av'
            print '2  - use net RSSM'
            print '3  - use net TPLINK'
            print '4  - disable net'
            print '5  - get wifi network name'
            print '6  - ping google'
            print '7  - test all avs'
            print '8  - test a single av'
            print '9 - is infected?'
            print '10 - got r00t?'
            print '11 - pull file'
            print '12 - push file'
            print ''
            print '#################     INTERNAL TESTS    #################'
            print '20 - test get_server'
            print '21 - test set_server'
            print '22 - test get_client'
            print '23 - test set_client'
            print '24 - test install'
            print '25 - test install_agent'
            print '26 - test uninstall'
            print '27 - test uninstall_agent'
            print '28 - test execute'
            print '29 - test execute_agent'
            print ''
            print '#################          EXIT         #################'
            print '99 - Clean & exit!'

            operation = raw_input()

            if operation == '1':
                print 'Which av you want to retrieve?'
                print str(apk_dataLoader.get_av_list())
                av = raw_input()
                commands.update(av, dev)

            elif operation == '2':
                commands.wifi('open', dev)

            elif operation == '3':
                commands.wifi('av', dev)

            elif operation == '4':
                commands.wifi('disable', dev)

            elif operation == '5':
                print commands.info_wifi_network(dev)

            elif operation == '6':
                if commands.can_ping_google(dev):
                    print "I can ping google"
                else:
                    print "I canNOT ping google"

            elif operation == '7':
                # TODO: andrebbe spostato il do_test
                for av in apk_dataLoader.get_av_list():
                    do_test(device, av)

            elif operation == '8':
                # TODO: andrebbe spostato il do_test
                print 'Which av you want to test?'
                print str(apk_dataLoader.get_av_list())
                av = raw_input()
                do_test(device, av)

            elif operation == '9':
                if commands.check_infection(dev):
                    print "Infected"
                else:
                    print "Clean"

            elif operation == '10':
                if commands.check_su_permissions(dev):
                    print "Root!"
                else:
                    print "Not root :("
            elif operation == '11':
                print '12 - pull file'
                commands.pull(['file.png'], '/sdcard/', 'tmp', dev)
                if os.path.exists('tmp/file.png'):
                    print 'Pull OK!'
                    #debug: time.sleep(20)
                    os.remove('tmp/file.png')
                else:
                    print 'Pull failed!'

            elif operation == '12':
                print '13 - push file'
                commands.push(['file.png'], 'assets', '/sdcard/', dev)

            elif operation == '20':
                print "testvarsrv= " + commands.get_server('testvarsrv')
            elif operation == '21':
                commands.set_server({'testvarsrv': 'testvaluesrv'})
            elif operation == '22':
                print "testvarcli= " + commands.get_client('testvarcli')
            elif operation == '23':
                commands.set_client({'testvarcli': 'testvaluecli'})
            elif operation == '24':
                commands.install('wifi_enabler', dev)
            elif operation == '25':
                commands.install_agent(dev)
            elif operation == '26':
                commands.uninstall('wifi_enabler', dev)
            elif operation == '27':
                commands.uninstall_agent(dev)
            elif operation == '28':
                commands.execute('wifi_enabler', dev)
            elif operation == '29':
                commands.execute_agent(dev)

        print "Operazioni terminate, cleaning time"
        commands.reset_device(dev)
        print "The end"
示例#8
0
                commands.install_agent(dev)
            elif operation == '26':
                commands.uninstall('wifi_enabler', dev)
            elif operation == '27':
                commands.uninstall_agent(dev)
            elif operation == '28':
                commands.execute('wifi_enabler', dev)
            elif operation == '29':
                commands.execute_agent(dev)

        print "Operazioni terminate, cleaning time"
        commands.reset_device(dev)
        print "The end"


'''


commands.update()
commands.pull()
commands.push()



wifi
info_wifi_network
can_ping_google
check_su_permissions
check_infection
init_device
reset_device
示例#9
0
    def log(self, command):
        self.instance.debug.addEvent(event="Update Plugin Commands", source="PLUGINLOG")
        self.instance.Listener.commandUpdate()
        commands.update()

        com = ""
        try:
            c = command.split()

            com = c[0].lower()

            del (c[0])
            args = c

        except:
            pass

        if com in " ":
            pass

        elif com == "pack":
            try:
                self.instance.installPackage(args[0])
                self.instance.installed.append(args[0])

            except:
                self.instance.docprint("please input the package name")
                a = self.instance.docinput("Packagename: ")
                try:
                    self.instance.installPackage(a)
                    self.instance.installed.append(a)

                except:
                    self.instance.docprint("no package available named " + a, consoleOutput=True)

        elif com in self.commands:
            objekt = self.commands[com]
            return eval(objekt)

        elif com in self.instance.installed:

            objekt = self.commands[com + " " + args[0]]

            obj = []

            obj = objekt.split(commands.key)

            for i in range(len(obj)):
                eval(obj[i])

            try:
                pass

            except:
                try:
                    self.instance.docprint(f"{com} has no command " + args[0])

                except:
                    self.instance.docprint(f"{com} is an installed Plugin")

        else:
            return "no command named " + com
示例#10
0
def main(argv):
    devices = adb.get_attached_devices()

    print """
    !!! Test AntiVirus !!!
    !!! Attenzione:    !!!
    !!! Prima dell'installazione dell'agente, al dispositivo va impedito il libero accesso ad internet. !!!
    """
    print """ prerequisiti:
    1) Telefono connesso in USB,
    2) USB Debugging enabled (settings/developer options/usb debugging)
    3) NESSUNA SIM INSTALLATA <======== NB!!!!!!!!!!!!!!!!!!!!!!!
    4) screen time 2m (settings/display/sleep)
    """

    print "devices connessi:"
    for device in devices:
        print device

    if not devices:
        print "non ci sono device connessi"
    else:

        if len(devices) > 1:
            dev = raw_input("su quale device si vuole eseguire il test? ")
            print "Eseguo il test su %s" % dev

        if len(sys.argv) >= 2:
            serialno = sys.argv[1]

        else:
            serialno = '.*'

        device = AdbClient(serialno=serialno)
        # print 'Args=', (str(sys.argv))
        # operation = sys.argv[1]

        init = raw_input('Init everything? (y/n)')
        if init == "y":
            print "Init!"
            commands.init_device(device.serialno)

        dev = device.serialno

        operation = -1

        while operation != "99":
            print ''
            print '#################       OPERATIONS      #################'
            print 'What operation do you want to perform?'
            print '1  - get new configuration from installed av'
            print '2  - use net RSSM'
            print '3  - use net TPLINK'
            print '4  - disable net'
            print '5  - get wifi network name'
            print '6  - ping google'
            print '7  - test all avs'
            print '8  - test a single av'
            print '9 - is infected?'
            print '10 - got r00t?'
            print '11 - pull file'
            print '12 - push file'
            print ''
            print '#################     INTERNAL TESTS    #################'
            print '20 - test get_server'
            print '21 - test set_server'
            print '22 - test get_client'
            print '23 - test set_client'
            print '24 - test install'
            print '25 - test install_agent'
            print '26 - test uninstall'
            print '27 - test uninstall_agent'
            print '28 - test execute'
            print '29 - test execute_agent'
            print ''
            print '#################          EXIT         #################'
            print '99 - Clean & exit!'

            operation = raw_input()

            if operation == '1':
                print 'Which av you want to retrieve?'
                print str(apk_dataLoader.get_av_list())
                av = raw_input()
                commands.update(av, dev)

            elif operation == '2':
                commands.wifi('open', dev)

            elif operation == '3':
                commands.wifi('av', dev)

            elif operation == '4':
                commands.wifi('disable', dev)

            elif operation == '5':
                print commands.info_wifi_network(dev)

            elif operation == '6':
                if commands.can_ping_google(dev):
                    print "I can ping google"
                else:
                    print "I canNOT ping google"

            elif operation == '7':
                # TODO: andrebbe spostato il do_test
                for av in apk_dataLoader.get_av_list():
                    do_test(device, av)

            elif operation == '8':
                # TODO: andrebbe spostato il do_test
                print 'Which av you want to test?'
                print str(apk_dataLoader.get_av_list())
                av = raw_input()
                do_test(device, av)

            elif operation == '9':
                if commands.check_infection(dev):
                    print "Infected"
                else:
                    print "Clean"

            elif operation == '10':
                if commands.check_su_permissions(dev):
                    print "Root!"
                else:
                    print "Not root :("
            elif operation == '11':
                print '12 - pull file'
                commands.pull(['file.png'], '/sdcard/', 'tmp', dev)
                if os.path.exists('tmp/file.png'):
                    print 'Pull OK!'
                    #debug: time.sleep(20)
                    os.remove('tmp/file.png')
                else:
                    print 'Pull failed!'

            elif operation == '12':
                print '13 - push file'
                commands.push(['file.png'], 'assets', '/sdcard/', dev)

            elif operation == '20':
                print "testvarsrv= " + commands.get_server('testvarsrv')
            elif operation == '21':
                commands.set_server({'testvarsrv': 'testvaluesrv'})
            elif operation == '22':
                print "testvarcli= " + commands.get_client('testvarcli')
            elif operation == '23':
                commands.set_client({'testvarcli': 'testvaluecli'})
            elif operation == '24':
                commands.install('wifi_enabler', dev)
            elif operation == '25':
                commands.install_agent(dev)
            elif operation == '26':
                commands.uninstall('wifi_enabler', dev)
            elif operation == '27':
                commands.uninstall_agent(dev)
            elif operation == '28':
                commands.execute('wifi_enabler', dev)
            elif operation == '29':
                commands.execute_agent(dev)

        print "Operazioni terminate, cleaning time"
        commands.reset_device(dev)
        print "The end"
示例#11
0
            elif operation == '25':
                commands.install_agent(dev)
            elif operation == '26':
                commands.uninstall('wifi_enabler', dev)
            elif operation == '27':
                commands.uninstall_agent(dev)
            elif operation == '28':
                commands.execute('wifi_enabler', dev)
            elif operation == '29':
                commands.execute_agent(dev)

        print "Operazioni terminate, cleaning time"
        commands.reset_device(dev)
        print "The end"

'''


commands.update()
commands.pull()
commands.push()



wifi
info_wifi_network
can_ping_google
check_su_permissions
check_infection
init_device
reset_device