From a61f7688ccdeb7fb9b939353d3b1b7559080eaff Mon Sep 17 00:00:00 2001 From: bjschuma Date: Sun, 20 Dec 2009 01:16:20 -0500 Subject: [PATCH] Prevent disable and enable from ever being disabled --- src/base/manager.py | 5 ++++- src/clean.sh | 4 ++++ src/core/cline/addch.py | 5 +++-- src/core/cline/run.py | 4 +++- src/core/disable.py | 39 +++++++++++++++++++++++++++++++++++++++ src/core/enable.py | 38 ++++++++++++++++++++++++++++++++++++++ src/core/reload.py | 3 +++ 7 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 src/clean.sh create mode 100644 src/core/disable.py create mode 100644 src/core/enable.py diff --git a/src/base/manager.py b/src/base/manager.py index 53f9e45b..d6bccb6d 100644 --- a/src/base/manager.py +++ b/src/base/manager.py @@ -83,7 +83,10 @@ class Manager: def run(self,name,args=None): - self.enabled[name].run(args) + name = name.strip() + + if (name in self.enabled)==True: + self.enabled[name].run(args) global manager diff --git a/src/clean.sh b/src/clean.sh new file mode 100644 index 00000000..4ce09705 --- /dev/null +++ b/src/clean.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rm -r ./*/*.pyc +rm -r ./*/*/*.pyc diff --git a/src/core/cline/addch.py b/src/core/cline/addch.py index 3d360fe0..fd0e9056 100644 --- a/src/core/cline/addch.py +++ b/src/core/cline/addch.py @@ -18,7 +18,7 @@ def addch(input): c = stdscr.getch() if c == 10: - enter(input) + input = enter(input) elif c == 127: input = backspace(input) @@ -42,4 +42,5 @@ def backspace(input): # Attempt to run a command def enter(input): - run(input) \ No newline at end of file + input = run(input) + return input \ No newline at end of file diff --git a/src/core/cline/run.py b/src/core/cline/run.py index cd53034f..3a8d54b5 100644 --- a/src/core/cline/run.py +++ b/src/core/cline/run.py @@ -11,9 +11,11 @@ from manager import manager # Check for valid input def run(input): + prompt = input[0:4] input = input[4:] - split = input.split() + split = input.strip().split() if len(split)>1: manager.run(split[0],split[1:]) else: manager.run(input) + return prompt diff --git a/src/core/disable.py b/src/core/disable.py new file mode 100644 index 00000000..cdb18fd0 --- /dev/null +++ b/src/core/disable.py @@ -0,0 +1,39 @@ +#! /usr/bin/python + +# To change this template, choose Tools | Templates +# and open the template in the editor. + +__author__="bjschuma" +__date__ ="$Dec 20, 2009 12:52:29 AM$" + + +global name, app, type, path, opt +name = "disable" +app = "scion" +type = "core" +path = "" +opt = [] + + +from manager import manager + + +# Called every time the plugin is enabled +def open(): + pass + + +# Called every time the plugin is stopped +def close(): + # Run this to prevent disable from ever being disabled + manager.run("enable",("disable")) + pass + + +# Called when the plugin needs to perform some action +def run(args=None): + if args == None: + return + + for plugin in args: + manager.disablePlugin(plugin) diff --git a/src/core/enable.py b/src/core/enable.py new file mode 100644 index 00000000..9b9298a7 --- /dev/null +++ b/src/core/enable.py @@ -0,0 +1,38 @@ +#! /usr/bin/python + +# To change this template, choose Tools | Templates +# and open the template in the editor. + +__author__="bjschuma" +__date__ ="$Dec 20, 2009 12:54:32 AM$" + + +global name, app, type, path, opt +name = "enable" +app = "scion" +type = "core" +path = "" +opt = [] + +from manager import manager + + +# Called every time the plugin is enabled +def open(): + pass + + +# Called every time the plugin is stopped +def close(): + # Prevent enable from ever being disabled + manager.enablePlugin("enable") + pass + + +# Called when the plugin needs to perform some action +def run(args=None): + if args == None: + return + + for plugin in args: + manager.enablePlugin(plugin) diff --git a/src/core/reload.py b/src/core/reload.py index b5bfd5a3..e0a87085 100644 --- a/src/core/reload.py +++ b/src/core/reload.py @@ -30,5 +30,8 @@ def close(): # Called when the plugin needs to perform some action def run(args=None): + if args == None: + return + for plugin in args: manager.reloadPlugin(plugin)