예제 #1
0
파일: Shell.py 프로젝트: BradMP/SimpleCV
def setup_shell():

    banner = "+-----------------------------------------------------------+\n"
    banner += " SimpleCV "
    banner += SIMPLECV_VERSION
    banner += " [interactive shell] - http://simplecv.org\n"
    banner += "+-----------------------------------------------------------+\n"
    banner += "\n"
    banner += "Commands: \n"
    banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
    banner += '\t"clear" to clear the shell screen\n'
    banner += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
    banner += '\t"example" gives a list of examples you can run\n'
    banner += '\t"forums" will launch a web browser for the help forums\n'
    banner += '\t"walkthrough" will launch a web browser with a walkthrough\n'
    banner += "\n"
    banner += "Usage:\n"
    banner += "\tdot complete works to show library\n"
    banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
    banner += "\tjust by touching TAB after typing Image().\n"
    banner += "\n"
    banner += "Documentation:\n"
    banner += "\thelp(Image), ?Image, Image?, or Image()? all do the same\n"
    banner += '\t"docs" will launch webbrowser showing documentation'
    banner += "\n"
    exit_msg = "\n... [Exiting the SimpleCV interactive shell] ...\n"

    # IPython version is less than 11
    if IPVER <= 10:
        # setup terminal to show SCV prompt
        argsv = ["-pi1", "SimpleCV:\\#>", "-pi2", "   .\\D.:", "-po", "SimpleCV:\\#>", "-nosep"]

        scvShell = IPShellEmbed(argsv)
        scvShell.set_banner(banner)
        scvShell.set_exit_msg(exit_msg)
        scvShell.IP.api.expose_magic("tutorial", magic_tutorial)
        scvShell.IP.api.expose_magic("clear", magic_clear)
        scvShell.IP.api.expose_magic("example", magic_examples)
        scvShell.IP.api.expose_magic("forums", magic_forums)
        scvShell.IP.api.expose_magic("walkthrough", magic_walkthrough)
        scvShell.IP.api.expose_magic("docs", magic_docs)

        return scvShell

    # IPython version 0.11 or higher
    else:
        cfg = Config()
        cfg.PromptManager.in_template = "SimpleCV:\\#> "
        cfg.PromptManager.out_template = "SimpleCV:\\#: "
        # ~ cfg.InteractiveShellEmbed.prompt_in1 = "SimpleCV:\\#> "
        # ~ cfg.InteractiveShellEmbed.prompt_out="SimpleCV:\\#: "
        scvShell = InteractiveShellEmbed(config=cfg, banner1=banner, exit_msg=exit_msg)
        scvShell.define_magic("tutorial", magic_tutorial)
        scvShell.define_magic("clear", magic_clear)
        scvShell.define_magic("example", magic_examples)
        scvShell.define_magic("forums", magic_forums)
        scvShell.define_magic("walkthrough", magic_walkthrough)
        scvShell.define_magic("docs", magic_docs)

        return scvShell
예제 #2
0
def main():
    clear()
    banner = '+----------------------------------------------------+\n'
    banner += ' SimpleCV [interactive shell]\n'
    banner += '+----------------------------------------------------+\n'
    banner += '\n'
    banner += 'Commands: \n'
    banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
    banner += '\t"clear" to clear the shell screen\n'
    banner += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
    banner += '\t"cheatsheet" gives a cheatsheet of all the shell functions\n' 
    banner += '\t"simplehelp" gives list of commands or help on a certain command\n'
    banner += '\t"example" gives a list of examples you can run'
    banner += '\n'
    banner += 'Usage:\n'
    banner += '\tdot complete works to show library\n'
    banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
    banner += '\tjust by touching TAB after typing Image().\n'
    banner += '\n'
    banner += 'API Documentation:\n'
    banner += '\t"help function_name" will give in depth documentation of API\n'
    banner += '\t\texample:'
    banner += 'help Image or ?Image\n'
    banner += '\t\twill give the in-depth information about that class\n'
    banner += '\t"?function_name" will give the quick API documentation\n'
    banner += '\t\texample:'
    banner += '?Image.save\n'
    banner += '\t\twill give help on the image save function'

    

    
    exit_msg = '\nExiting the SimpleCV interactive shell\n'
    

    #setup terminal to show SCV prompt
    argsv = ['-pi1','SimpleCV:\\#>','-pi2','   .\\D.:','-po','SimpleCV:\\#>','-nosep']

    scvShell = IPShellEmbed(argsv)
    scvShell.set_banner(banner)
    scvShell.set_exit_msg(exit_msg)
    scvShell.IP.api.expose_magic("tutorial",magic_tutorial)
    scvShell.IP.api.expose_magic("clear", magic_clear)
    scvShell.IP.api.expose_magic("simplehelp", magic_help)
    scvShell.IP.api.expose_magic("cheatsheet", magic_cheatsheet)
    scvShell.IP.api.expose_magic("example", magic_examples)
    

    #Note that all loaded libraries are inherited in the embedded ipython shell
    sys.exit(scvShell())
예제 #3
0
def setup_shell():
    banner = '+----------------------------------------------------+\n'
    banner += ' SimpleCV [interactive shell] - http://simplecv.org\n'
    banner += '+----------------------------------------------------+\n'
    banner += '\n'
    banner += 'Commands: \n'
    banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
    banner += '\t"clear" to clear the shell screen\n'
    banner += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
    banner += '\t"cheatsheet" gives a cheatsheet of all the shell functions\n'
    banner += '\t"example" gives a list of examples you can run'
    banner += '\n'
    banner += 'Usage:\n'
    banner += '\tdot complete works to show library\n'
    banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
    banner += '\tjust by touching TAB after typing Image().\n'
    banner += 'API Documentation:\n'
    banner += '\t"help function_name" will give in depth documentation of API\n'
    banner += '\texample: help Image\n'
    banner += 'Editor:\n'
    banner += '\t"editor" will run the SimpleCV code editor in a browser\n'
    banner += '\t\texample:'
    banner += 'help Image or ?Image\n'
    banner += '\t\twill give the in-depth information about that class\n'
    banner += '\t"?function_name" will give the quick API documentation\n'
    banner += '\t\texample:'
    banner += '?Image.save\n'
    banner += '\t\twill give help on the image save function'
    exit_msg = '\nExiting the SimpleCV interactive shell\n'

    #setup terminal to show SCV prompt
    argsv = [
        '-pi1', 'SimpleCV:\\#>', '-pi2', '   .\\D.:', '-po', 'SimpleCV:\\#>',
        '-nosep'
    ]

    scvShell = IPShellEmbed(argsv)
    scvShell.set_banner(banner)
    scvShell.set_exit_msg(exit_msg)
    scvShell.IP.api.expose_magic("tutorial", magic_tutorial)
    scvShell.IP.api.expose_magic("clear", magic_clear)
    scvShell.IP.api.expose_magic("cheatsheet", magic_cheatsheet)
    scvShell.IP.api.expose_magic("example", magic_examples)
    scvShell.IP.api.expose_magic("editor", magic_editor)

    return scvShell
예제 #4
0
파일: Shell.py 프로젝트: blackball/SimpleCV
def setup_shell():  
    banner = '+----------------------------------------------------+\n'
    banner += ' SimpleCV [interactive shell] - http://simplecv.org\n'
    banner += '+----------------------------------------------------+\n'
    banner += '\n'
    banner += 'Commands: \n'
    banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
    banner += '\t"clear" to clear the shell screen\n'
    banner += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
    banner += '\t"cheatsheet" gives a cheatsheet of all the shell functions\n' 
    banner += '\t"example" gives a list of examples you can run'
    banner += '\n'
    banner += 'Usage:\n'
    banner += '\tdot complete works to show library\n'
    banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
    banner += '\tjust by touching TAB after typing Image().\n'
    banner += 'API Documentation:\n'
    banner += '\t"help function_name" will give in depth documentation of API\n'
    banner += '\texample: help Image\n'
    banner += 'Editor:\n'
    banner += '\t"editor" will run the SimpleCV code editor in a browser\n'
    banner += '\t\texample:'
    banner += 'help Image or ?Image\n'
    banner += '\t\twill give the in-depth information about that class\n'
    banner += '\t"?function_name" will give the quick API documentation\n'
    banner += '\t\texample:'
    banner += '?Image.save\n'
    banner += '\t\twill give help on the image save function'
    exit_msg = '\nExiting the SimpleCV interactive shell\n'
    

    #setup terminal to show SCV prompt
    argsv = ['-pi1','SimpleCV:\\#>','-pi2','   .\\D.:','-po','SimpleCV:\\#>','-nosep']

    scvShell = IPShellEmbed(argsv)
    scvShell.set_banner(banner)
    scvShell.set_exit_msg(exit_msg)
    scvShell.IP.api.expose_magic("tutorial",magic_tutorial)
    scvShell.IP.api.expose_magic("clear", magic_clear)
    scvShell.IP.api.expose_magic("cheatsheet", magic_cheatsheet)
    scvShell.IP.api.expose_magic("example", magic_examples)
    scvShell.IP.api.expose_magic("editor", magic_editor)
    
    return scvShell
예제 #5
0
파일: icli.py 프로젝트: rep/pwrcall
import sys
from IPython.Shell import IPShellEmbed
from evnet import pyevThread
from pwrcall import Node, expose, loop, unloop
from pwrcall.util import NodeException, parse_url

CERT = 'clientside.pem'
t = pyevThread()
t.start()
n = Node(cert=CERT)
ipshell = IPShellEmbed()

def establish(pwrurl):
	return t.blockingCall(n.establish, pwrurl)

def pwrcall(obj, fn, *args):
	return t.blockingCall(obj.call, fn, *args)	

if __name__ == '__main__':
	ipshell.set_banner(
'''pwrcall Interactive Shell
-------------------------
starts up a evnet loop and pwrcall Node
use the Node through the t.blockingCall function''')
	ipshell.set_exit_msg('Exit.')
	ipshell()
	sys.exit(0)

예제 #6
0
        banner = '*** Starting Interactive Shell - Ctrl-D to exit...\n\nnapi is your NexposeAPI variable to play with\n'

        if IPython.__version__ >= "0.11":
            from IPython.config.loader import Config
            cfg = Config()
            cfg.InteractiveShellEmbed.prompt_in1="myprompt [\\#]> "
            cfg.InteractiveShellEmbed.prompt_out="myprompt [\\#]: "
            #cfg.InteractiveShellEmbed.profile=ipythonprofile
            # directly open the shell
            IPython.embed(config=cfg, banner2=banner)
        else:
            try:
                from IPython.Shell import IPShellEmbed
                argv = ['-pi1','In <\\#>:','-pi2','   .\\D.:','-po','Out<\\#>:']
                ipshell = IPShellEmbed(argv,banner='*** Starting Interactive Shell - Ctrl-D to exit...\n\nnapi is your NexposeAPI variable to play with\n')
                ipshell.set_exit_msg('Buh-bye!')
                ipshell()
            except ImportError, e:
                sys.exit("IPython not installed, won't continue...")

    if options.listvulns:
        vuln_class = VulnData(napi.sessionid)
        vuln_class.populate_summary()
        if (vuln_class.vulnerabilities) > 0:
            if options.listvulns.upper() == "CSV":
                print vuln_class.csvout()
            else:
                print vuln_class.vulnxml
        else:
            print "Error: No Vulnerabilities loaded, check your Nexpose server address or user/pass"
예제 #7
0
파일: Shell.py 프로젝트: ilibx/SimpleCV
def setup_shell():

  banner = '+-----------------------------------------------------------+\n'
  banner += ' SimpleCV '
  banner += SIMPLECV_VERSION
  banner += ' [interactive shell] - http://simplecv.org\n'
  banner += '+-----------------------------------------------------------+\n'
  banner += '\n'
  banner += 'Commands: \n'
  banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
  banner += '\t"clear" to clear the shell screen\n'
  banner += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
  banner += '\t"example" gives a list of examples you can run\n'
  banner += '\t"forums" will launch a web browser for the help forums\n'
  banner += '\t"walkthrough" will launch a web browser with a walkthrough\n'
  banner += '\n'
  banner += 'Usage:\n'
  banner += '\tdot complete works to show library\n'
  banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
  banner += '\tjust by touching TAB after typing Image().\n'
  banner += '\n'
  banner += 'Documentation:\n'
  banner += '\thelp(Image), ?Image, Image?, or Image()? all do the same\n'
  banner += '\t"docs" will launch webbrowser showing documentation'
  banner += '\n'
  exit_msg = '\n... [Exiting the SimpleCV interactive shell] ...\n'
  


  #IPython version is less than 11
  if IPVER <= 10:
    #setup terminal to show SCV prompt
    argsv = ['-pi1','SimpleCV:\\#>','-pi2','   .\\D.:','-po','SimpleCV:\\#>','-nosep']

    scvShell = IPShellEmbed(argsv)
    scvShell.set_banner(banner)
    scvShell.set_exit_msg(exit_msg)
    scvShell.IP.api.expose_magic("tutorial",magic_tutorial)
    scvShell.IP.api.expose_magic("clear", magic_clear)
    scvShell.IP.api.expose_magic("example", magic_examples)
    scvShell.IP.api.expose_magic("forums", magic_forums)
    scvShell.IP.api.expose_magic("walkthrough", magic_walkthrough)
    scvShell.IP.api.expose_magic("docs", magic_docs)

    return scvShell

  #IPython version 0.11 or higher
  else:
    cfg = Config()
    cfg.PromptManager.in_template = "SimpleCV:\\#> "
    cfg.PromptManager.out_template = "SimpleCV:\\#: "
    #~ cfg.InteractiveShellEmbed.prompt_in1 = "SimpleCV:\\#> "
    #~ cfg.InteractiveShellEmbed.prompt_out="SimpleCV:\\#: "
    scvShell = InteractiveShellEmbed(config=cfg, banner1=banner, exit_msg = exit_msg)
    scvShell.define_magic("tutorial",magic_tutorial)
    scvShell.define_magic("clear", magic_clear)
    scvShell.define_magic("example", magic_examples)
    scvShell.define_magic("forums", magic_forums)
    scvShell.define_magic("walkthrough", magic_walkthrough)
    scvShell.define_magic("docs", magic_docs)

    return scvShell
예제 #8
0
# They also print an exit message every time they exit.

# Both the startup banner and the exit message default to None, and can be set
# either at the instance constructor or at any other time with the
# set_banner() and set_exit_msg() methods.

# The shell instance can be also put in 'dummy' mode globally or on a per-call
# basis. This gives you fine control for debugging without having to change
# code all over the place.

# The code below illustrates all this.

# This is how the global banner and exit_msg can be reset at any point
ipshell.set_banner('Entering interpreter - New Banner')
ipshell.set_exit_msg('Leaving interpreter - New exit_msg')


def foo(m):
    s = 'spam'
    ipshell('***In foo(). Try @whos, or print s or m:')
    print 'foo says m = ', m


def bar(n):
    s = 'eggs'
    ipshell('***In bar(). Try @whos, or print s or n:')
    print 'bar says n = ', n


# Some calls to the above functions which will trigger IPython:
예제 #9
0
# They also print an exit message every time they exit.

# Both the startup banner and the exit message default to None, and can be set
# either at the instance constructor or at any other time with the
# set_banner() and set_exit_msg() methods.

# The shell instance can be also put in 'dummy' mode globally or on a per-call
# basis. This gives you fine control for debugging without having to change
# code all over the place.

# The code below illustrates all this.


# This is how the global banner and exit_msg can be reset at any point
ipshell.set_banner('Entering interpreter - New Banner')
ipshell.set_exit_msg('Leaving interpreter - New exit_msg')

def foo(m):
    s = 'spam'
    ipshell('***In foo(). Try @whos, or print s or m:')
    print 'foo says m = ',m

def bar(n):
    s = 'eggs'
    ipshell('***In bar(). Try @whos, or print s or n:')
    print 'bar says n = ',n
    
# Some calls to the above functions which will trigger IPython:
print 'Main program calling foo("eggs")\n'
foo('eggs')
예제 #10
0
def setup_shell():

    banner = '+----------------------------------------------------+\n'
    banner += ' SimpleCV [interactive shell] - http://simplecv.org\n'
    banner += '+----------------------------------------------------+\n'
    banner += '\n'
    banner += 'Commands: \n'
    banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
    banner += '\t"clear" to clear the shell screen\n'
    banner += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
    banner += '\t"cheatsheet" gives a cheatsheet of all the shell functions\n'
    banner += '\t"example" gives a list of examples you can run'
    banner += '\n'
    banner += 'Usage:\n'
    banner += '\tdot complete works to show library\n'
    banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
    banner += '\tjust by touching TAB after typing Image().\n'
    banner += 'API Documentation:\n'
    banner += '\t"help function_name" will give in depth documentation of API\n'
    banner += '\texample: help Image\n'
    banner += 'Editor:\n'
    banner += '\t"editor" will run the SimpleCV code editor in a browser\n'
    banner += '\t\texample:'
    banner += 'help Image or ?Image\n'
    banner += '\t\twill give the in-depth information about that class\n'
    banner += '\t"?function_name" will give the quick API documentation\n'
    banner += '\t\texample:'
    banner += '?Image.save\n'
    banner += '\t\twill give help on the image save function'
    exit_msg = '\n... [Exiting the SimpleCV interactive shell] ...\n'

    #IPython version is less than 11
    if IPVER <= 10:
        #setup terminal to show SCV prompt
        argsv = [
            '-pi1', 'SimpleCV:\\#>', '-pi2', '   .\\D.:', '-po',
            'SimpleCV:\\#>', '-nosep'
        ]

        scvShell = IPShellEmbed(argsv)
        scvShell.set_banner(banner)
        scvShell.set_exit_msg(exit_msg)
        scvShell.IP.api.expose_magic("tutorial", magic_tutorial)
        scvShell.IP.api.expose_magic("clear", magic_clear)
        scvShell.IP.api.expose_magic("cheatsheet", magic_cheatsheet)
        scvShell.IP.api.expose_magic("example", magic_examples)
        scvShell.IP.api.expose_magic("editor", magic_editor)

        return scvShell

    #IPython version 0.11 or higher
    else:
        cfg = Config()
        cfg.PromptManager.in_template = "SimpleCV:\\#> "
        cfg.PromptManager.out_template = "SimpleCV:\\#: "
        #~ cfg.InteractiveShellEmbed.prompt_in1 = "SimpleCV:\\#> "
        #~ cfg.InteractiveShellEmbed.prompt_out="SimpleCV:\\#: "
        scvShell = InteractiveShellEmbed(config=cfg,
                                         banner1=banner,
                                         exit_msg=exit_msg)
        scvShell.define_magic("tutorial", magic_tutorial)
        scvShell.define_magic("clear", magic_clear)
        scvShell.define_magic("cheatsheet", magic_cheatsheet)
        scvShell.define_magic("example", magic_examples)
        scvShell.define_magic("editor", magic_editor)

        return scvShell
예제 #11
0
import sys
from IPython.Shell import IPShellEmbed
from evnet import pyevThread
from pwrcall import Node, expose, loop, unloop
from pwrcall.util import NodeException, parse_url

CERT = 'clientside.pem'
t = pyevThread()
t.start()
n = Node(cert=CERT)
ipshell = IPShellEmbed()


def establish(pwrurl):
    return t.blockingCall(n.establish, pwrurl)


def pwrcall(obj, fn, *args):
    return t.blockingCall(obj.call, fn, *args)


if __name__ == '__main__':
    ipshell.set_banner('''pwrcall Interactive Shell
-------------------------
starts up a evnet loop and pwrcall Node
use the Node through the t.blockingCall function''')
    ipshell.set_exit_msg('Exit.')
    ipshell()
    sys.exit(0)
예제 #12
0
def setup_shell():
  
  banner = '+----------------------------------------------------+\n'
  banner += ' SimpleCV [interactive shell] - http://simplecv.org\n'
  banner += '+----------------------------------------------------+\n'
  banner += '\n'
  banner += 'Commands: \n'
  banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
  banner += '\t"clear" to clear the shell screen\n'
  banner += '\t"tutorial" to begin the SimpleCV interactive tutorial\n'
  banner += '\t"cheatsheet" gives a cheatsheet of all the shell functions\n' 
  banner += '\t"example" gives a list of examples you can run'
  banner += '\n'
  banner += 'Usage:\n'
  banner += '\tdot complete works to show library\n'
  banner += '\tfor example: Image().save("/tmp/test.jpg") will dot complete\n'
  banner += '\tjust by touching TAB after typing Image().\n'
  banner += 'API Documentation:\n'
  banner += '\t"help function_name" will give in depth documentation of API\n'
  banner += '\texample: help Image\n'
  banner += 'Editor:\n'
  banner += '\t"editor" will run the SimpleCV code editor in a browser\n'
  banner += '\t\texample:'
  banner += 'help Image or ?Image\n'
  banner += '\t\twill give the in-depth information about that class\n'
  banner += '\t"?function_name" will give the quick API documentation\n'
  banner += '\t\texample:'
  banner += '?Image.save\n'
  banner += '\t\twill give help on the image save function'
  exit_msg = '\n... [Exiting the SimpleCV interactive shell] ...\n'


  #IPython version is less than 11
  if IPVER <= 10:
    #setup terminal to show SCV prompt
    argsv = ['-pi1','SimpleCV:\\#>','-pi2','   .\\D.:','-po','SimpleCV:\\#>','-nosep']

    scvShell = IPShellEmbed(argsv)
    scvShell.set_banner(banner)
    scvShell.set_exit_msg(exit_msg)
    scvShell.IP.api.expose_magic("tutorial",magic_tutorial)
    scvShell.IP.api.expose_magic("clear", magic_clear)
    scvShell.IP.api.expose_magic("cheatsheet", magic_cheatsheet)
    scvShell.IP.api.expose_magic("example", magic_examples)
    scvShell.IP.api.expose_magic("editor", magic_editor)
    
    return scvShell

  #IPython version 0.11 or higher
  else:
    cfg = Config()
    cfg.PromptManager.in_template = "SimpleCV:\\#> "
    cfg.PromptManager.out_template = "SimpleCV:\\#: "
    #~ cfg.InteractiveShellEmbed.prompt_in1 = "SimpleCV:\\#> "
    #~ cfg.InteractiveShellEmbed.prompt_out="SimpleCV:\\#: "
    scvShell = InteractiveShellEmbed(config=cfg, banner1=banner, exit_msg = exit_msg)
    scvShell.define_magic("tutorial",magic_tutorial)
    scvShell.define_magic("clear", magic_clear)
    scvShell.define_magic("cheatsheet", magic_cheatsheet)
    scvShell.define_magic("example", magic_examples)
    scvShell.define_magic("editor", magic_editor)

    return scvShell