github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

pmuellr / nitro_pie

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 5
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (1)
  • Downloads (2)
  • Wiki (2)
  • Graphs
  • Tree: 55efaee

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (2)
    • v0.5
    • 0.6
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Python bindings for JavaScriptCore — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

added nps (shell), fixed doc, labeled 0.5 
pmuellr (author)
Wed Apr 22 08:58:11 -0700 2009
commit  55efaee97fde3a93451d5cbce8c66b68bf2bb610
tree    71adc56b94e25baa9d1c51a70b6fb2432f35db1b
parent  38f25e2498a13f0495037413ffb33a9261f71e27
nitro_pie / nps / nps.py nps/nps.py
100755 66 lines (46 sloc) 1.916 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
 
import os
import sys
 
#-------------------------------------------------------------------------------
def callback_print(context, function, thisObject, args):
    line = ""
    
    for arg in args:
        if JSObject.isJSObject(arg):
            printable = arg.toString()
        else:
            printable = str(arg)
    
        line = line + printable
        
    print line
    
#-------------------------------------------------------------------------------
 
lib_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../lib"))
if lib_path not in sys.path: sys.path.insert(0, lib_path)
 
from nitro_pie import *
 
if len(sys.argv) < 2:
    print "Excepting the name of a script to run"
    sys.exit(1)
    
script_file_name = sys.argv[1]
script_file = open(script_file_name)
script = script_file.read()
script_file.close()
    
context = JSContext()
 
globalObject = context.getGlobalObject()
 
function = context.makeFunctionWithCallback("print", callback_print)
globalObject.setProperty("print", function)
 
try:
    globalObject = context.getGlobalObject()
    globalObject = None
    result = context.eval(script, globalObject, script_file_name, 1)
    
except JSException, e:
    e = e.value
    
    name = e.getProperty("name") if e.hasProperty("name") else ""
    message = e.getProperty("message") if e.hasProperty("message") else "???"
    sourceURL = e.getProperty("sourceURL") if e.hasProperty("sourceURL") else "???"
    line = e.getProperty("line") if e.hasProperty("line") else -1
 
    print "Exception thrown: %s: %s: at %s[%d]" % (name, message, sourceURL, line)
 
    props = e.getPropertyNames()
    known_props = "name message sourceURL line".split()
    for prop in props:
        if prop in known_props: continue
        print " %s: %s" % (prop, e.getProperty(prop))
    print
        
context.release()
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server