[{"pk": 4, "model": "sh.shclasses", "fields": {"comment": "List Applications", "lang": "python", "name": "ListApps", "field": "Application", "parents": [], "deps": [], "public": false}}, {"pk": 5, "model": "sh.shclasses", "fields": {"comment": "This application aims to implement some kind of REST (well, really a kind of) interface to the landscape", "lang": "python", "name": "ShCommand", "field": "Service", "parents": [], "deps": [6], "public": false}}, {"pk": 6, "model": "sh.shclasses", "fields": {"comment": "Read POST & GET data and make it available in an unified way", "lang": "python", "name": "HTTPRequest", "field": "Network", "parents": [], "deps": [], "public": false}}, {"pk": 7, "model": "sh.shclasses", "fields": {"comment": "Post things on HTTP, takes number of fields as GET'n'] arguments", "lang": "python", "name": "Post", "field": "Application", "parents": [], "deps": [6], "public": false}}, {"pk": 12, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "XHR", "field": "Network", "parents": [], "deps": [], "public": false}}, {"pk": 13, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "JSLoader", "field": "Util", "parents": [], "deps": [], "public": false}}, {"pk": 14, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "Commander", "field": "Util", "parents": [], "deps": [12, 18], "public": false}}, {"pk": 15, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "Workspace", "field": "Application", "parents": [], "deps": [13], "public": false}}, {"pk": 16, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "JQWidget", "field": "UiBase", "parents": [], "deps": [], "public": false}}, {"pk": 17, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "JQMethodWidget", "field": "UiBase", "parents": [], "deps": [16], "public": false}}, {"pk": 18, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "JQClassWidget", "field": "UiBase", "parents": [16], "deps": [], "public": false}}, {"pk": 19, "model": "sh.shclasses", "fields": {"comment": "Wrapper on a canvas element", "lang": "js", "name": "CanvasView", "field": "Graphic", "parents": [], "deps": [], "public": false}}, {"pk": 20, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "JQCanvasWidget", "field": "UiBase", "parents": [16], "deps": [], "public": false}}, {"pk": 21, "model": "sh.shclasses", "fields": {"comment": "Wrapper for os module", "lang": "python", "name": "OSCommand", "field": "Service", "parents": [], "deps": [6], "public": false}}, {"pk": 22, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "OSTerminal", "field": "UiBase", "parents": [16], "deps": [], "public": false}}, {"pk": 23, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "Fontforge", "field": "LGRU", "parents": [], "deps": [], "public": false}}, {"pk": 24, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "LGRU", "field": "Application", "parents": [], "deps": [], "public": false}}, {"pk": 25, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "Media", "field": "Service", "parents": [], "deps": [], "public": true}}, {"pk": 26, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "TestMedia", "field": "Application", "parents": [], "deps": [], "public": true}}, {"pk": 3, "model": "sh.shmethods", "fields": {"comment": "", "body": "htmlopen = r' Lazy Landscape Shell '\nhtmlClose = ''\nstyle = r' '\ntitle = r'

Applications

'\n\nret = [htmlopen, style, title]\n\n\nfor c in ShClasses.objects.filter(lang='python').filter(field='Application'):\n hasexec = False\n for m in c.methods.all():\n if m.name == 'app':\n hasexec = True\n break\n \n exec_warning = ''\n if not hasexec:\n exec_warning = '
This app lacks an \"app\" method.
'\n \n ret += r'
%s
%s
' % (c.name, c.name, c.comment, exec_warning)\n \nret += '
'\nret += htmlClose\n\nresponse.write(''.join(ret))", "args": "", "name": "app", "cls": 4}}, {"pk": 4, "model": "sh.shmethods", "fields": {"comment": "", "body": "self._d = {}\r\nfor k in request.POST:\r\n self._d[ k ] = request.POST[k]\r\n \r\nfor k in request.GET:\r\n self._d[ k ] = request.GET[k]", "args": "request", "name": "__init__", "cls": 6}}, {"pk": 5, "model": "sh.shmethods", "fields": {"comment": "", "body": "self.args = Network.HTTPRequest(request)\r\nself.parse()", "args": "", "name": "app", "cls": 5}}, {"pk": 6, "model": "sh.shmethods", "fields": {"comment": "", "body": "if self.args.has('command'):\r\n if hasattr(self, self.args.command) and callable(getattr(self, self.args.command)):\r\n getattr(self, self.args.command)()", "args": "", "name": "parse", "cls": 5}}, {"pk": 7, "model": "sh.shmethods", "fields": {"comment": "", "body": "tattr = attr\r\nif isinstance(attr, basestring):\r\n tattr = [attr]\r\nfor i in tattr:\r\n if i not in self._d:\r\n return False\r\nreturn True", "args": "attr", "name": "has", "cls": 6}}, {"pk": 8, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['field','name','lang']):\r\n response.write(self.json.dumps({'error':'not enough args'}))\r\n \r\ncls = ShClasses()\r\nfor i in ['field','name','comment','lang']:\r\n if self.args.has(i):\r\n setattr(cls, i, getattr(self.args, i))\r\n \r\ncls.save()\r\nresponse.write('

OK: %s.%s (%s) created

%s'%(cls.field,cls.name,cls.lang,cls.comment))\r\n#response.write(self.json.dumps(cls))", "args": "", "name": "new_class", "cls": 5}}, {"pk": 9, "model": "sh.shmethods", "fields": {"comment": "", "body": "args = Network.HTTPRequest(request)\r\nif args.has(['app']):\r\n app = args.app\r\n ret = ['
']\r\n for a in args.all():\r\n if a != 'app':\r\n if getattr(args,a) == 't':\r\n ret.append('
'+a+':
')\r\n else:\r\n ret.append('
'+a+':
')\r\n ret.append('
'%(app))\r\n response.write('\\n'.join(ret))", "args": "", "name": "app", "cls": 7}}, {"pk": 10, "model": "sh.shmethods", "fields": {"comment": "", "body": "return self._d.keys()", "args": "", "name": "all", "cls": 6}}, {"pk": 11, "model": "sh.shmethods", "fields": {"comment": "", "body": "if name in self._d:\r\n return self._d[name]\r\nelse:\r\n raise AttributeError('HTTPRequest.%s is not defined' % (name))", "args": "name", "name": "__getattr__", "cls": 6}}, {"pk": 12, "model": "sh.shmethods", "fields": {"comment": "", "body": "self.json = __import__('json', globals(), locals(), [], -1)", "args": "", "name": "__init__", "cls": 5}}, {"pk": 14, "model": "sh.shmethods", "fields": {"comment": "", "body": "this.xhr = new XMLHttpRequest();", "args": "", "name": "init", "cls": 12}}, {"pk": 15, "model": "sh.shmethods", "fields": {"comment": "", "body": "this.xhr.open(\"GET\", url, false);\r\nthis.xhr.send(null);", "args": "url", "name": "get", "cls": 12}}, {"pk": 16, "model": "sh.shmethods", "fields": {"comment": "", "body": "if(data != undefined)\r\nthis.xhr.data = data\r\nthis.xhr.addEventListener(\"load\", fn, false);\r\nreturn this;", "args": "fn, data", "name": "bind", "cls": 12}}, {"pk": 17, "model": "sh.shmethods", "fields": {"comment": "", "body": "this.xhr.open(\"POST\", url, false);\r\nthis.xhr.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\r\nthis.xhr.send(this.aToD(data));", "args": "url, data", "name": "post", "cls": 12}}, {"pk": 18, "model": "sh.shmethods", "fields": {"comment": "", "body": "jstr = []\r\nfor i in jlist:\r\n jstr.append(''%(i[0], i[1]))\r\n\r\nself.js = '\\n'.join(jstr)", "args": "jlist", "name": "__init__", "cls": 13}}, {"pk": 19, "model": "sh.shmethods", "fields": {"comment": "", "body": "var ret = ''\r\nfor(var n in a)\r\n{\r\n if(n != undefined && a[n] != undefined)\r\n ret += encodeURIComponent(n) + '=' + encodeURIComponent(a[n]) + '&';\r\n}\r\nreturn ret;", "args": "a", "name": "aToD", "cls": 12}}, {"pk": 20, "model": "sh.shmethods", "fields": {"comment": "Takes a selector for the 'source' container of commands and a callback to process whatever comes back from a command", "body": "var eList = document.querySelectorAll(source);\r\nif(eList.length > 0)\r\n{\r\n var cont = eList[0];\r\n var csource = document.createElement(\"input\");\r\n var submit = document.createElement(\"span\");\r\n submit.textContent = '|Get Class|';\r\n\tsubmit.setAttribute('class','command-submit link');\r\n cont.appendChild(csource);\r\n cont.appendChild(submit);\r\n \r\n submit.source = csource;\r\n submit.xhr = Network.New('XHR');\r\n submit.xhr.bind(this.handleCommand);\r\n submit.addEventListener('click', function(e)\r\n {\r\n\t\tvar cstr = this.source.value.split('/');\r\n\t\tvar data = {command :'get_class', field:cstr[0], name:cstr[1]};\r\n\t this.xhr.post('/Service/ShCommand', data);\r\n });\r\n \r\n}\r\n", "args": "source", "name": "init", "cls": 14}}, {"pk": 21, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['field','name']):\r\n response.write( self.json.dumps({'error':'not enough args'}))\r\n \r\ntry:\r\n cls = ShClasses.objects.get(field=self.args.field, name=self.args.name)\r\n # list methods\r\n ms = {}\r\n for i in cls.methods.all():\r\n ms[i.name] = {'name': i.name, 'id':i.id,'args':i.args, 'body':i.body, 'comment':i.comment, 'klass': cls.name}\r\n o = {'id': cls.id,\r\n 'field': cls.field,\r\n 'name': cls.name,\r\n 'comment' : cls.comment,\r\n 'lang' : cls.lang,\r\n 'methods': ms,}\r\n response.write( self.json.dumps(o))\r\nexcept:\r\n response.write( self.json.dumps({'error':'Class does not exist for F(%s) N(%s)'%(self.args.field, self.args.name)}))\r\n \r\n", "args": "", "name": "get_class", "cls": 5}}, {"pk": 22, "model": "sh.shmethods", "fields": {"comment": "", "body": "jscmd = Util.JSLoader([['Util', 'Commander'],['UiBase', 'JQMethodWidget'], ['UiBase','OSTerminal']])\nscript = \"\"\"\n\n\n\"\"\"\n\n\nself.os = ' Workspace '+jscmd.js+' '+script+'
'", "args": "", "name": "__init__", "cls": 15}}, {"pk": 23, "model": "sh.shmethods", "fields": {"comment": "", "body": "response.write(self.os)", "args": "", "name": "app", "cls": 15}}, {"pk": 24, "model": "sh.shmethods", "fields": {"comment": "", "body": "if(window._widget_reg == undefined)\n{\n window._widget_reg = {};\n}\n\nif(window._widget_reg[id] != undefined)\n{\n\tvar ww = window._widget_reg[id];\n\tif(ww.minimized)\n\t\tww.restore();\n return ww;\n}\n\nvar widget = jQuery('
');\nvar titletext = jQuery(''+title+'');\nvar title = jQuery('
');\nvar viewport = jQuery('
');\n\ntitle.append(titletext);\nwidget.append(title);\nwidget.append(viewport);\nviewport.css({ overflow: 'auto' });\nwidget.draggable({ \n addClasses:true,\n appendTo:\"parent\",\n axis:false,\n connectToSortable:false,\n containment:false,\n cursor:\"auto\",\n cursorAt:false,\n grid:false,\n handle:title,\n helper:\"original\",\n iframeFix:false,\n opacity:false,\n refreshPositions:false,\n revert:false,\n revertDuration:500,\n scope:\"default\",\n scroll:true,\n scrollSensitivity:20,\n scrollSpeed:20,\n snap:false,\n snapMode:\"both\",\n snapTolerance:20,\n stack:false,\n zIndex:0\n });\nwidget.resizable({\n alsoResize:viewport,\n animate:false,\n animateDuration:\"slow\",\n animateEasing:\"swing\",\n aspectRatio:false,\n autoHide:false,\n containment:false,\n ghost:false,\n grid:false,\n handles:\"se\",\n helper:false,\n maxHeight:null,\n maxWidth:null,\n minHeight:10,\n minWidth:10,\n zIndex:0\n });\n\nwidget.minimized = false;\n\nwidget.title = title;\nwidget.titletext = titletext;\nwidget.viewport = viewport;\nwidget.css({position:'absolute', width:'300px', top: '100px', left:'100px'});\njQuery('body').append(widget);\nwidget.restore = this.restore;\nwidget.minimize = this.minimize;\nwidget.close = this.close;\nthis.set_tools(widget);\nwindow._widget_reg[id] = widget;\nthis.widget = widget;\nreturn widget;", "args": "id, title", "name": "init", "cls": 16}}, {"pk": 25, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['id']):\r\n response.write( self.json.dumps({'error':'not enough args'}))\r\n\r\nsh = __import__('sh')\r\ncls = None\r\ntry:\r\n cls = sh.models.ShMethods.objects.get(pk=self.args.id)\r\nexcept:\r\n response.write( self.json.dumps({'error':'No method with ID %s'%(self.args.id,)}))\r\n return\r\n \r\no = {'id': cls.id,\r\n'name': cls.name,\r\n'comment' : cls.comment,\r\n'args' : cls.args,\r\n'body': cls.body,\r\n'lang' : cls.cls.lang, }\r\nresponse.write( self.json.dumps(o))\r\n", "args": "", "name": "get_method", "cls": 5}}, {"pk": 26, "model": "sh.shmethods", "fields": {"comment": "", "body": "\nif(window._widget_reg['m_' + id] != undefined)\n{\n\tthis.base = window._widget_reg['m_' + id];\n\tthis.base.restore(this.base);\n}\nelse\n{\n\tthis.base = UiBase.New('JQWidget','m_' + id, title);\n\tthis.code_widget = jQuery('');\n\tthis.submit = jQuery('');\n\t\n\tthis.base.widget.viewport.append(this.code_widget);\n\tthis.base.widget.viewport.append(this.submit);\n\t\n\tvar xhr = Network.New('XHR');\n\tvar data = {'command' : 'get_method', 'id': id};\n\txhr.bind(this.handleMethod, {'widget':this});\n\txhr.post('/Service/ShCommand', data);\n\t\n\tthis.submit.bind('click', {'mid':id, 'widget':this, 'callback' : this.handleMethod}, this.save_method);\n}\n", "args": "id, title", "name": "init", "cls": 17}}, {"pk": 27, "model": "sh.shmethods", "fields": {"comment": "", "body": "var data = JSON.parse(this.responseText);\n\nif(data.error == undefined)\n{\n var that = this.data.widget;\n that.code_widget.val(data.body);\n var cm_opt = {};\n if(data.lang == 'js')\n cm_opt = {lineWrapping: true, mode: \"javascript\", lineNumbers: true, indentWithTabs: true, indentUnit: 4, tabMode: \"shift\", matchBrackets: true };\n else\n cm_opt = {lineWrapping: true, mode: {name: \"python\", version: 2, singleLineStringErrors: false}, lineNumbers: true, indentWithTabs: true, indentUnit: 4, tabMode: \"shift\", matchBrackets: true };\n that.cm = CodeMirror.fromTextArea(that.code_widget[0], cm_opt);\n that.base.widget.bind( \"resizestop\", function(event, ui) \n {\n var t = that.cm.getValue();\n that.cm.setValue('');\n that.cm.refresh();\n that.cm.setValue(t);\n });\n}\nelse\n alert(data.error)", "args": "", "name": "handleMethod", "cls": 17}}, {"pk": 28, "model": "sh.shmethods", "fields": {"comment": "", "body": "var xhr = Network.New('XHR');\r\nvar data = {'command' : 'save_method', 'id': event.data.mid, 'body':event.data.widget.cm.getValue()};\r\nxhr.bind(event.data.widget.callback, {'widget':event.data.widget});\r\nxhr.post('/Service/ShCommand', data);", "args": "event", "name": "save_method", "cls": 17}}, {"pk": 29, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['id','body']):\n response.write( self.json.dumps({'error':'not enough args'}))\n\nsh = __import__('sh')\ncls = None\ntry:\n cls = sh.models.ShMethods.objects.get(pk=self.args.id)\nexcept:\n response.write( self.json.dumps({'error':'No method with ID %s'%(self.args.id,)}))\n return\n\ncls.body = self.args.body\ncls.save()\n \no = {'id': cls.id,\n'name': cls.name,\n'comment' : cls.comment,\n'args' : cls.args,\n'body': cls.body,\n'lang' : cls.cls.lang }\nresponse.write( self.json.dumps(o))\n\n", "args": "", "name": "save_method", "cls": 5}}, {"pk": 30, "model": "sh.shmethods", "fields": {"comment": "", "body": "var util_bar = jQuery('#util_bar');\r\nif(util_bar.length == 0)\r\n{\r\n\tutil_bar = jQuery('
');\r\n\tjQuery('body').append(util_bar);\r\n}\r\nvar restorefunc = this.restore;\r\nvar widget = this;\r\nthis.titletext.click(function(){restorefunc(widget);});\r\nthis.titletext.addClass('link');\r\nthis.minimized = true;\r\nthis.storepos = {'left' : this.offset().left, 'top': this.offset().top};\r\nthis.storedim = {width: this.width(), height: this.height()};\r\nthis.viewport.hide();\r\nutil_bar.append(this);\r\nthis.css({position:'static', width: 'auto', height: 'auto'});\r\n", "args": "", "name": "minimize", "cls": 16}}, {"pk": 31, "model": "sh.shmethods", "fields": {"comment": "", "body": "jQuery('body').append(widget);\r\n\r\nwidget.titletext.unbind('click');\r\nwidget.titletext.removeClass('link');\r\nwidget.minimized = false;\r\nwidget.css({position :'relative'});\r\nwidget.width(widget.storedim.width);\r\nwidget.height(widget.storedim.height);\r\nwidget.offset(widget.storepos);\r\nwidget.viewport.show();", "args": "widget", "name": "restore", "cls": 16}}, {"pk": 32, "model": "sh.shmethods", "fields": {"comment": "", "body": "var toolbox = jQuery('
|
');\r\nvar close = jQuery(' x ');\r\nvar minim = jQuery(' - ');\r\n\r\nclose.click(function(){widget.close();});\r\nminim.click(function(){widget.minimize();});\r\n\r\ntoolbox.append(close);\r\ntoolbox.append(minim);\r\nwidget.title.prepend(toolbox);", "args": "widget", "name": "set_tools", "cls": 16}}, {"pk": 33, "model": "sh.shmethods", "fields": {"comment": "", "body": "var id = this.attr('id');\r\ndelete window._widget_reg[id];\r\nthis.remove();", "args": "id", "name": "close", "cls": 16}}, {"pk": 34, "model": "sh.shmethods", "fields": {"comment": "", "body": "var wid = 'klass_' + cls.id;\nvar wtitle = cls.field + '.' + cls.name + ' ('+cls.lang+')';\nthis.Parent().init(wid, wtitle);\nthis.widget.viewport.addClass('pdng_s');\nthis.methodbox = jQuery('
');\nthis.widget.viewport.append(this.methodbox);\nfor(var mn in cls.methods)\n{\n\tthis.method_item(cls.methods[mn]);\n}\n\nvar new_m = jQuery('
');\nvar new_i = jQuery('');\nvar new_s = jQuery('new');\nnew_i.class_id = cls.id;\nnew_m.append(new_i);\nnew_m.append(new_s);\nnew_s.bind('click',{that:this,input:new_i},this.make_new);\nthis.widget.viewport.append(new_m);", "args": "cls", "name": "init", "cls": 18}}, {"pk": 35, "model": "sh.shmethods", "fields": {"comment": "", "body": "var that = event.data.that;\nif(event.data.input.val().length > 0)\n{\n\tjQuery.post('/Service/ShCommand', \n\t\t\t\t{command:'new_method',\n\t\t\t\t cls: event.data.input.class_id,\n\t\t\t\t name: event.data.input.val()},\n\t\t\t\tfunction(data){\n\t\t\t\t\tvar d = JSON.parse(data);\n\t\t\t\t\tif(d.error != undefined)\n\t\t\t\t\t\talert(d.error);\n\t\t\t\t\telse\n\t\t\t\t\t\tthat.method_item(d);\n\t\t\t\t});\n\tevent.data.input.val('');\n}", "args": "event", "name": "make_new", "cls": 18}}, {"pk": 36, "model": "sh.shmethods", "fields": {"comment": "Make an entry in the list of methods", "body": "var mcom = jQuery('');\nthis.methodbox.append(mcom);\nmcom.bind('click', {'mid': method.id, 'title': method.klass+'.'+method.name} ,function(event){\n\tUiBase.New('JQMethodWidget', event.data.mid, event.data.title);\n});\nvar minfo = jQuery('
'+method.comment+'
');\nthis.methodbox.append(minfo);", "args": "method", "name": "method_item", "cls": 18}}, {"pk": 37, "model": "sh.shmethods", "fields": {"comment": "", "body": "var d = JSON.parse(this.responseText);\r\nif(d.error != undefined)\r\n\talert(d.error);\r\nelse\r\n{\r\n\tUiBase.New('JQClassWidget', d);\r\n}", "args": "data", "name": "handleCommand", "cls": 14}}, {"pk": 38, "model": "sh.shmethods", "fields": {"comment": "", "body": "var c = jQuery(cont);\nif(c.length > 0)\n{\n\tthis._canvas = jQuery('');\n\tc.append(this._canvas);\n}\nreturn this;", "args": "cont, width, height", "name": "init", "cls": 19}}, {"pk": 39, "model": "sh.shmethods", "fields": {"comment": "", "body": "this.wid = 'cnvs_' + (Math.floor(Math.random() * 1000000000));\nthis.Parent().init(this.wid, wtitle);\nvar cont = jQuery('
');\njQuery('body').append(cont);\nthis._cview = Graphic.New('CanvasView', 'cont_'+this.wid, 600, 600);\nthis.widget.viewport.append(this._cview._canvas);\nreturn this;\n", "args": "", "name": "init", "cls": 20}}, {"pk": 40, "model": "sh.shmethods", "fields": {"comment": "Return actual canvas element", "body": "", "args": "", "name": "canvas", "cls": 20}}, {"pk": 41, "model": "sh.shmethods", "fields": {"comment": "", "body": "self.os = __import__('os', globals(), locals(), [], -1)\nself.json = __import__('json', globals(), locals(), [], -1)", "args": "", "name": "__init__", "cls": 21}}, {"pk": 42, "model": "sh.shmethods", "fields": {"comment": "", "body": "args = Network.HTTPRequest(request)\nif args.has('command'):\n\trid = ''\n\tif args.has('rid'):\n\t\trid = args.rid\n if hasattr(self.os, args.command) and callable(getattr(self.os, args.command)):\n\t\tlargs = []\n\t\tret = None\n\t\tif(args.has(['args'])):\n\t\t\tlargs = [x for x in args.args.split(',') if x]\n\t\t\t#largs = args.args.split(',')\n\t\ttry:\n\t\t\tif len(largs) == 0:\n\t\t\t\tret = getattr(self.os, args.command)()\n\t\t\telif len(largs) == 1:\n\t\t\t\tret = getattr(self.os, args.command)(largs[0])\n\t\t\telif len(largs) == 2:\n\t\t\t\tret = getattr(self.os, args.command)(largs[0], largs[1])\n\t\t\telif len(largs) == 3:\n\t\t\t\tret = getattr(self.os, args.command)(largs[0], largs[1], largs[2])\n\t\t\telif len(largs) == 4:\n\t\t\t\tret = getattr(self.os, args.command)(largs[0], largs[1], largs[2], largs[3])\n\t\texcept Exception as e:\n\t\t\tresponse.write(self.json.dumps({'rid': rid,'error' : '%s(%s) raised [%s]' % (args.command,largs,e)}))\n\t\t\treturn\n\t\t\t\n\t\tresponse.write(self.json.dumps({'rid': rid, 'result' : ret}))\n\telse:\n\t\tresponse.write(self.json.dumps({'rid': rid,'error':'%s not found' % (args.command,)}))\nelse:\n\tresponse.write(self.json.dumps({'rid': rid,'error' : 'No command'}))\n\t\t\t\n\t\t\t", "args": "", "name": "app", "cls": 21}}, {"pk": 43, "model": "sh.shmethods", "fields": {"comment": "", "body": "var id = (Math.floor(Math.random() * 1000000000));\nvar wid = 'osterm_' + id;\nvar rid = 'rb_' + id;\nvar wtitle = 'osTerminal';\nthis.Parent().init(wid, wtitle);\n\n\n\nthis.input = jQuery('');\nthis.submit = jQuery('submit');\nthis.response_box = jQuery('
');\n\nthis.widget.viewport.append(this.input);\nthis.widget.viewport.append(this.submit);\nthis.widget.viewport.append(this.response_box);\n\nvar that = this;\nthis.submit.bind('click', \n\t\t\t\t {input : this.input, \n\t\t\t\t responsebox : this.response_box}, \n\t\t\t\t function(event)\n\t\t\t\t {\n\t\t\t\t\t var li = event.data.input.val().split(' ');\n\t\t\t\t\t if(li.length > 0)\n\t\t\t\t\t {\n\t\t\t\t\t\t var com = li.shift();\n\t\t\t\t\t\t var args = '';\n\t\t\t\t\t\t var sep = '';\n\t\t\t\t\t\t for(var i =0; i < li.length; i++)\n\t\t\t\t\t\t {\n\t\t\t\t\t\t\t args += sep + li[i];\n\t\t\t\t\t\t\t sep = ',';\n\t\t\t\t\t\t }\n\t\t\t\t\t\t jQuery.post('/Service/OSCommand',\n\t\t\t\t\t\t\t\t\t\t\t\t\t {rid:rid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t command:com,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t args:args},\n\t\t\t\t\t\t\t\t\t\t\t\t\tthat.handleResult);\n\t\t\t\t\t }\n\t\t\t\t });\n\n", "args": "", "name": "init", "cls": 22}}, {"pk": 44, "model": "sh.shmethods", "fields": {"comment": "", "body": "var data = JSON.parse(text);\nif(data.error != undefined)\n{\n\talert(data.error);\n}\nelse\n{\n\tvar rb = jQuery('#'+data.rid);\n\trb.append('
'+data.result+'
');\n}", "args": "text", "name": "handleResult", "cls": 22}}, {"pk": 45, "model": "sh.shmethods", "fields": {"comment": "Wrap Fontforge module", "body": "self.fontforge = __import__('fontforge')", "args": "", "name": "__init__", "cls": 23}}, {"pk": 46, "model": "sh.shmethods", "fields": {"comment": "", "body": "return getattr(self.fontforge, name)", "args": "name", "name": "__getattr__", "cls": 23}}, {"pk": 47, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['cls','name']):\n response.write( self.json.dumps({'error':'not enough args'}))\n\t\nsh = __import__('sh')\t\ncls = None\ntry:\n\tcls = ShClasses(pk=self.args.cls)\nexcept Exception as e:\n\tresponse.write(self.json.dumps({'error':'No class with id = %s to attach this method to.\\n %s'%(self.args.cls,e,)}))\nelse:\n\tm = sh.models.ShMethods()\n\tm.cls = cls\n\tfor i in ['name','comment','args','body']:\n\t\tif self.args.has(i):\n\t\t\tsetattr(m, i, getattr(self.args, i))\n\t\t\t\n\tm.save()\n\to = {'id': m.id,\n\t'name': m.name,\n\t'comment' : m.comment,\n\t'args' : m.args,\n\t'body': m.body,\n\t'lang': m.cls.lang }\n\tresponse.write( self.json.dumps(o))\n", "args": "", "name": "new_method", "cls": 5}}, {"pk": 48, "model": "sh.shmethods", "fields": {"comment": "", "body": "", "args": "", "name": "__init__", "cls": 24}}, {"pk": 49, "model": "sh.shmethods", "fields": {"comment": "", "body": "", "args": "", "name": "test", "cls": 24}}, {"pk": 50, "model": "sh.shmethods", "fields": {"comment": "", "body": "ll = __import__('lazylandscape')\r\nself.root = ll.settings.MEDIA_ROOT\r\nif not self.root.endswith('/'):\r\n\tself.root = self.root + '/'\r\n\t\r\nself.mime = __import__('mimetypes')\r\nself.mime.init()\r\n\r\nself.os = __import__('os')\r\nself.json = __import__('json')", "args": "", "name": "__init__", "cls": 25}}, {"pk": 51, "model": "sh.shmethods", "fields": {"comment": "", "body": "os = __import__('os')\r\nif not os.path.exists(self.filepath(path)):\r\n\tresponse.status_code = '404 Not Found'\r\n\tresponse.write('

File %s not found

'%(self.filepath(path),))\r\n\treturn\r\nf = open(self.filepath(path), 'rb')\r\ntry:\r\n\tmt = self.mime.guess_type(self.filepath(path))\r\n\ttype = mt[0]\r\n\tenc = ''\r\n\tif mt[1]:\r\n\t\tenc = ';' + mt[1]\r\n\tresponse['Content-Type'] = type + enc\r\n\tresponse['Content-Length'] = self.os.path.getsize(self.filepath(path))\r\n\tresponse.write(f.read())\r\nexcept Exception as e:\r\n\tresponse.write('

Exception occured

%s'%(e,))\r\nfinally:\r\n\tf.close()", "args": "path", "name": "GetFile", "cls": 25}}, {"pk": 52, "model": "sh.shmethods", "fields": {"comment": "", "body": "json = __import__('json')\r\nif request.FILES and 'push_media' in request.FILES.keys():\r\n\tp = self.filepath(path)\r\n\tf = request.FILES['push_media']\r\n\tif not self.os.path.isdir(p):\r\n\t\ttry:\r\n\t\t\tself.os.makedirs(p)\r\n\t\texcept self.os.error:\r\n\t\t\tresponse.write(json.dumps({'error':'Cannot create dir'}))\r\n\t\t\treturn\r\n\tdestination = open(p + '/' + f.name , 'wb+')\r\n\ttry:\r\n\t\tfor chunk in f.chunks():\r\n\t\t\tdestination.write(chunk)\r\n\texcept Exception:\r\n\t\tresponse.write(json.dumps({'error':'Cannot write'}))\r\n\tfinally:\r\n\t\tdestination.close()\r\nelse:\r\n\tresponse.write(json.dumps({'error':'Nothing to push dude'}))", "args": "path", "name": "PushFile", "cls": 25}}, {"pk": 54, "model": "sh.shmethods", "fields": {"comment": "", "body": "if 'get_media' in request.POST.keys():\r\n\treturn self.GetFile(request.POST['get_media'])\r\nelif 'get_media' in request.GET.keys():\r\n\treturn self.GetFile(request.GET['get_media'])\r\nif 'list_media' in request.POST.keys():\r\n\treturn self.ListFiles(request.POST['list_media'])\r\nif 'list_media' in request.GET.keys():\r\n\treturn self.ListFiles(request.GET['list_media'])\r\nelif 'push_media_path' in request.POST.keys():\r\n\treturn self.PushFile(request.POST['push_media_path'])\r\n\t\r\nresponse.write('

???

')", "args": "", "name": "app", "cls": 25}}, {"pk": 55, "model": "sh.shmethods", "fields": {"comment": "", "body": "r = \"\"\"\n\nTestMedia\n\n\n\n\n
\n\n\n
\n
\n\n\n\n
\n
\n\n\n\n\"\"\"\n\nresponse.write(r)\n", "args": "", "name": "app", "cls": 26}}, {"pk": 56, "model": "sh.shmethods", "fields": {"comment": "", "body": "return self.root + p", "args": "p", "name": "filepath", "cls": 25}}, {"pk": 57, "model": "sh.shmethods", "fields": {"comment": "", "body": "p = self.filepath(path)\nl = self.os.listdir(p)\n\nfiles = []\ndirs = []\nfor i in l:\n\tif self.os.path.isdir(p+'/'+i):\n\t\tdirs.append(path + '/' +i)\n\telse:\n\t\tfiles.append(path + '/' +i)\n\t\t\nresponse.write(self.json.dumps({'dirs' : dirs, 'files': files}))", "args": "path", "name": "ListFiles", "cls": 25}}]