Exemplo n.º 1
0
 def random_surf(self):
     link_or_form = self._random_pick()
     from IPython import Shell
     Shell.IPShellEmbed()()
     if isinstance(link_or_form, Link):
         self._follow_link(link_or_form)
     elif isinstance(link_or_form, Form):
         self._use_form(link_or_form)
Exemplo n.º 2
0
def newcomment(request, urlCode):
    """Adds a new comment to the database"""
    output = "OK"
    debugvar = 0
    try:
        if (request.method == "POST"):
            name = request.POST["name"]
            name = javaScriptEscape(name)
            message = request.POST["message"]
            message = javaScriptEscape(message)
            side = request.POST["side"]
            side = javaScriptEscape(side)
            chunk = int(request.POST["chunk"])
            line = int(request.POST["line"])

            # basic sanity check
            if (not (side == 'lhs' or side == 'rhs')):
                output = "ERROR"
            else:
                targetPatch = get_object_or_404(Patch, pk=urlCode)
                print "patch - ", urlCode, " chunknum ", chunk
                targetChunks = Chunk.objects.filter(patch=targetPatch,
                                                    chunkNum=chunk)
                print "Target chunks length - " + str(len(targetChunks))
                targetChunk = targetChunks[0]
                newComment = Comment()
                newComment.chunk = targetChunk
                newComment.commentAuthor = name
                newComment.commentText = message
                newComment.diffSide = side
                newComment.commentLine = line
                newComment.chunkID = chunk
                newComment.commentID = 0

                newComment.save()
        else:
            output = "ERROR"
    except Exception as e:
        from IPython import Shell
        Shell.IPShellEmbed()
        print "exception ", e
        output = "ERROR"
    return HttpResponse(output)
Exemplo n.º 3
0
 def do_ipshell(self, line):
     ipshell = Shell.IPShellEmbed()
     ipshell()
Exemplo n.º 4
0
    label = "knows"
    created = DateTime(default=current_datetime, nullable=False)


#from people import Person, Knows
from bulbs.neo4jserver import Graph


def build_parser():
    parser = argparse.ArgumentParser(conflict_handler='resolve')
    parser.add_argument('-w', '--worker', action='store_true')
    return parser


if __name__ == '__main__':
    parser = build_parser()
    args = parser.parse_args()
    g = Graph()
    g.config.set_logger(DEBUG)
    g.add_proxy("people", Person)
    g.add_proxy("knows", Knows)

    james = g.people.create(name="James")
    julie = g.people.create(name="Julie")
    relationship = g.knows.create(james, julie)
    friends = james.outV('knows')
    friends = julie.inV('knows')
    print relationship.data()
    from IPython import Shell
    Shell.IPShellEmbed(argv=['-noconfirm_exit'])()
Exemplo n.º 5
0
    def help(self):
        for item in APIREF.items():
            print "%s\t%s" % item

if __name__ == '__main__':
    nargs = len(sys.argv[1:])
    if nargs < 2 or nargs > 3:
        print "usage: %s username password [machine]" % sys.argv[0]
        sys.exit()

    banner = """
    A convenient Webfaction api wrapper
    See docs: http://docs.webfaction.com/xmlrpc-api/apiref.html
    Available objects: api
    example:
        api.create_createdb
        api.list_dbs()
        api.system('ls')
        api.help()
    Just do not use session_id parameter that it is already
    added to each api call."""

    try:
        api = Webfaction(*sys.argv[1:])
    except xmlrpclib.Fault, e:
        print >> sys.stderr, "RPC Error: %s" % e
    else:
        from IPython import Shell
        Shell.IPShellEmbed([], banner)()
    
Exemplo n.º 6
0
def ipython():
    from IPython import Shell
    Shell.IPShellEmbed(argv=['-noconfirm_exit'])()
Exemplo n.º 7
0
 def execute(self, *args):
     ipshell = Shell.IPShellEmbed()
     ipshell()