Пример #1
0
	def set(self, args):
		try:
			self.modadd.variables[args[0]][0] = args[1]
			print(colors.bold+args[0] +" => "+ str(args[1]) + colors.end)

		except (NameError, KeyError):
			print("["+colors.bold+colors.red+"err"+colors.end+"] Option is not found!")
			raise VariableError("["+colors.bold+colors.red+"err"+colors.end+"] Option is not found!")
		except IndexError:
			print("["+colors.bold+colors.red+"err"+colors.end+"] Invalid value!")
			raise VariableError("["+colors.bold+colors.red+"err"+colors.end+"] Invalid value!")
		except:
			print("["+colors.bold+colors.red+"err"+colors.end+"] Unexpected error in module:\n")
			traceback.print_exc(file=sys.stdout)
			print(colors.end)
			if api.enabled == True:
				raise
Пример #2
0
    def set(self, args):
        try:
            self.modadd.variables[args[0]][0] = args[1]
            print(colors.bold + args[0] + " => " + str(args[1]) + colors.end)

        except (NameError, KeyError):
            print(colors.red + "option not found" + colors.end)
            raise VariableError("option not found")
        except IndexError:
            print(colors.red + "please enter variable's value" + colors.end)
            raise VariableError("no value")
        except:
            print(colors.red + "unexpected error in module:\n")
            traceback.print_exc(file=sys.stdout)
            print(colors.end)
            if api.enabled == True:
                raise
Пример #3
0
    def handle(self, command):
        # String to list
        command = command.split()

        # Custom command
        if self.mm.moduleLoaded == 1:
            try:
                return self.cm.mcu(command)
            except IndexError:
                return
            except UnknownCommand:
                pass

        # Validate command

        if len(command) != 0 and command[0] in self.notcommand:
            print("[" + colors.bold + colors.red + "err" + colors.end +
                  "] Unrecognized command!" + colors.end)
            return
        try:
            method = getattr(self.cm, command[0])
        except AttributeError:
            print("[" + colors.bold + colors.red + "err" + colors.end +
                  "] Unrecognized command!" + colors.end)
            return
        except IndexError:
            return

        try:
            return method(command[1:])
        except UnknownCommand:
            print("[" + colors.bold + colors.red + "err" + colors.end +
                  "] Unrecognized command!" + colors.end)

        except ModuleNotFound:
            if self.api == True:
                raise ModuleNotFound("[" + colors.bold + colors.red + "err" +
                                     colors.end + "] Module is not found!")

        except VariableError:
            if self.api == True:
                raise VariableError("[" + colors.bold + colors.red + "err" +
                                    colors.end + "] Variable error!")