コード例 #1
0
    def addCommandArrayResource(self, commandName):
        print COLOR_GREEN
        result = raw_input(
            "add Command to Command resource or not(q = quit, any key to continue)"
        )
        if result == 'q':
            return

        name = des = group = keyword = hot = usage = ""
        line = command()
        print COLOR_WHITE
        while 1:
            name = line.setName(commandName)
            des = line.setDescription(updateCommandDescriptionInput())
            group = line.setGroup(updateCommandGroupInput())
            keyword = line.setKeyword(updateCommandKeywordsInput())
            hot = line.setIsHot(updateCommandHotInput())
            usage = line.setUsage(updateCommandUsageInput())

            result = confirmChange4Command(name, des, group, keyword, hot,
                                           usage)
            if result == 1:  # finlish the update
                self.setCommandResourceData(line)
                print COLOR_GREEN, "add Command to Command resource finished"
                break
            elif result == 0:  #re-run the update the command
                continue
            else:  #cancel
                break
コード例 #2
0
    def delcomm(self, delparse):
        line = delparse.message.split(" ", 1)[1]
        comm = command(line)

        for commands in self.commandlist:
            usedtrigger = False
            usedchannel = False
            useduser = False

            if comm.trigger == commands.trigger:
                usedtrigger = True
                for chan in comm.channels:
                    if chan in commands.channels:
                        usedchannel = True
                for user in comm.users:
                    if user in commands.users:
                        useduser = True

            if usedtrigger and usedchannel and useduser:
                self.commandlist.remove(commands)
                self.bot.say(delparse.channel, "deleted command: " + comm.trigger)

                txt = ""
                for comm in self.commandlist:
                    txt += comm.line + "\n"

                print(txt)
                f = open("commlist.txt", "w")
                f.write(txt)
                f.close()
                return
コード例 #3
0
    def addcomm(self, addparse):
        line = addparse.message.split(" ", 1)[1]
        comm = command(line)

        freecomm = True

        for commands in self.commandlist:
            freetrigger = True
            freechannel = True
            freeuser = True
            if comm.trigger == commands.trigger:
                freetrigger = False
                for chan in comm.channels:
                    if chan in commands.channels:
                        freechannel = False
                for user in comm.users:
                    if user in commands.users:
                        freeuser = False
            if not freetrigger and not freechannel and not freeuser:
                freecomm = False

        if freecomm:
            self.commandlist.append(comm)
            self.bot.say(addparse.channel, "added command: " + comm.trigger)

            with open("commlist.txt", "r+") as f:
                data = f.read()
                f.seek(0)
                f.write(data + "\n" + line)
                f.truncate()

        else:
            self.bot.say(addparse.channel, "command already in use: " + comm.trigger)
コード例 #4
0
 def getcommands(self):
     commands = []
     with open("commlist.txt") as f:
         for line in f.readlines():
             if line != "\n":
                 commands.append(command(line))
         print(time.ctime() + ": successfully read commandlist")
     return commands
コード例 #5
0
def recordCommand(queue):
    print 'recording command'
    record_to_file('stt.wav')
    #os.system("avconv -i stt.wav  -y -ar 16000 stt.flac")
    #with open('stt.flac','r') as f:
    #    speech=f.read()
    #text=speech_to_text(speech)
    c = command('audio command')
    queue.put(c)
コード例 #6
0
 def importData(self):
     if self.commandFilePath != "":
         csvReader = csv.reader(file(self.commandFilePath, 'r'))
         index = 0
         ca = []
         for line in csvReader:
             if index > 0:
                 c = command(line[0], line[1], line[2], line[3], line[4],
                             line[5])
                 ca.append(c)
             index += 1
         self.setCommandArray(ca)
         if len(self.commandArray) == 0:
             print COLOR_RED, "parsing command resource file failed\n"
             return -1
         else:
             return 0
     else:
         print COLOR_RED, "invalid linux command resource file path : ", self.commandFilePath, "\n"
         return -1
コード例 #7
0
def parseRow(row):
	s = row.split('=', 1)
	cmd = s[0]
	oper = s[1]
	command(cmd, oper)
コード例 #8
0
ファイル: service.py プロジェクト: BackupTheBerlios/pida-svn
 def __call_command(self, command, **kw):
     return command(**kw)
コード例 #9
0
ファイル: primitives.py プロジェクト: chromakode/josie
		def try_cmd(object):
			for command in object.commands.values():
				m = command.get_regex().match(cmd)
				if m is not None:
					if command(*m.groups()): return True
			return False
コード例 #10
0
#
# main page!
#
from android import Android
from world import World
from command import *


world = World()
me = Android('2B')

command(me, world)