コード例 #1
0
    def _list_files(self):
        """ returns a list of files this person has on storage,
          return empty list [] if unsuccessful
      """

        _list = []
        for _file in storage.keys():
            if not _file.startswith('/pyschool'): continue
            try:
                _fileobj = FileObject.FileObject()
                #_fileobj=FileSystemBase.FileObject()
                _fileobj.from_json(storage[_file])
            except Exception as e:
                #not a FileObject file..
                console.log(str(e))
                console.log('not a fileobject...', _file)
                continue

            _list.append({
                'filename':
                _fileobj.get_filename(),
                'modified_date':
                _fileobj.get_attribute('modified_date')
            })

        return {'status': 'Okay', 'filelist': _list}
コード例 #2
0
ファイル: mouse.py プロジェクト: 40123210/-2015cd_40123210
def get_pos():
    global _canvas
    if _canvas is None:
        _c = document.get(selector='canvas')
        if len(_c) > 0:
            _canvas = _c[0]
            console.log(_canvas.id)
            _canvas.mousemove = _getMousePosition

    return _mouse_x, _mouse_y
コード例 #3
0
ファイル: mouse.py プロジェクト: 2014c2g14/2015cd_midterm
def get_pos():
    global _canvas
    if _canvas is None:
       _c=document.get(selector='canvas')
       if len(_c) > 0:
          _canvas=_c[0]
          console.log(_canvas.id)
          _canvas.mousemove=_getMousePosition

    return _mouse_x, _mouse_y
コード例 #4
0
  def _remote_call(self, data):
      console.log("remote call", data)
      data['token']=self._token   #add in token to call
      _json=json.dumps({'data': data})

      try:
        _fp,_url,_headers=urllib.request.urlopen(self._baseURL, _json)
        return _fp.read()   #returns a string (in json format)
      except:
        return json.dumps({'status': 'Error', 
                           'message': 'Network connectivity issues'})
コード例 #5
0
def lookup(encoding):
    """lookup(encoding) -> CodecInfo    
    Looks up a codec tuple in the Python codec registry and returns
    a CodecInfo object."""

    if encoding in ('utf-8', 'utf_8'):
        from javascript import console
        console.log('encoding', encoding)
        import encodings.utf_8
        return encodings.utf_8.getregentry()

    LookupError(encoding)
コード例 #6
0
ファイル: _codecs.py プロジェクト: 2014c2g23/w16b_test
def lookup(encoding):
    """lookup(encoding) -> CodecInfo    
    Looks up a codec tuple in the Python codec registry and returns
    a CodecInfo object."""

    if encoding in ('utf-8', 'utf_8'):
       from javascript import console
       console.log('encoding', encoding)
       import encodings.utf_8
       return encodings.utf_8.getregentry()

    LookupError(encoding)
コード例 #7
0
ファイル: image.py プロジェクト: j-waters/Aiopa-Web-Server
    def img_onload(*args):
        #http://www.jaypan.com/tutorial/javascript-passing-arguments-anonymous-functions-without-firing-function
        #the onload files very slow so variables get messed up so we have
        #to use args[0].path[0] to figure out the correct image
        console.log(args)
        if hasattr(args[0], 'target'):  # Firefox
            this = args[0].target
        else:  #chrome
            this = args[0].path[0]

        this.canvas.width = this.width
        this.canvas.height = this.height
        this.canvas.getContext('2d').drawImage(this, 0, 0)
コード例 #8
0
    def img_onload(*args):
        #http://www.jaypan.com/tutorial/javascript-passing-arguments-anonymous-functions-without-firing-function
        #the onload files very slow so variables get messed up so we have
        #to use args[0].path[0] to figure out the correct image
        console.log(args)
        if hasattr(args[0], 'target'):   # Firefox
           this=args[0].target
        else:                            #chrome
           this=args[0].path[0]

        this.canvas.width=this.width
        this.canvas.height=this.height
        this.canvas.getContext('2d').drawImage(this,0,0)
コード例 #9
0
ファイル: draw.py プロジェクト: 40123210/-2015cd_40123210
  def __interval(self):
      if not self._queue.empty():
         _dict=self._queue.get()

         if _dict['type'] == 'LINE':
            self._ctx.beginPath()
            self._ctx.moveTo(_dict['x0'], _dict['y0'])
            self._ctx.lineTo(_dict['x1'], _dict['y1'])
            #if _dict['outline'] is not None:
            #   self._ctx.strokeStyle=_dict['outline']   #set line color
            if _dict['color'] is not None:
               self._ctx.fillStyle=_dict['color']
            self._ctx.stroke()
         elif _dict['type'] == 'POLYGON':
            if self._bg is not None:
               self._ctx.putImageData(self._bg[0], self._bg[1], self._bg[2])
               console.log(self._bg[0])
               self._bg=None

            self._ctx.beginPath()
            _moveTo=_dict['moveTo']
            self._ctx.moveTo(_moveTo[0], _moveTo[1])
            for _segment in _dict['segments']:
                self._ctx.lineTo(_segment[0], _segment[1])

            if _dict['width']:
               self._ctx.lineWidth=_dict['width']
            if _dict['outline']:
               self._ctx.strokeStyle=_dict['outline']
            if _dict['color']:
                self._ctx.fillStyle=_dict['color']
                self._ctx.fill() 

            self._ctx.closePath()
            self._ctx.stroke()
         elif _dict['type'] == 'POLYGON_BG':
            _x0,_y0,_x1,_y1=self.rect_from_shape(_dict['shape'])
            console.log(_x0,_y0,_x1, _y1)
            self._bg=[]
            self._bg.append(self._ctx.getImageData(_x0,_y0,abs(_x1)-abs(_x0),abs(_y1)-abs(_y0)))
            self._bg.append(_x0)
            self._bg.append(_y0)
コード例 #10
0
  def _list_files(self):
      """ returns a list of files this person has on storage,
          return empty list [] if unsuccessful
      """

      _list=[]
      for _file in storage.keys():
          if not _file.startswith('/pyschool'): continue
          try:
            _fileobj=FileObject.FileObject()
            #_fileobj=FileSystemBase.FileObject()
            _fileobj.from_json(storage[_file])
          except Exception as e:
            #not a FileObject file..
            console.log(str(e))
            console.log('not a fileobject...', _file)
            continue

          _list.append({'filename': _fileobj.get_filename(), 
                        'modified_date': _fileobj.get_attribute('modified_date')})

      return {'status': 'Okay', 'filelist': _list}
コード例 #11
0
 def err_msg(*args):
     from javascript import console
     console.log(args)
コード例 #12
0
def test_calls(iterations):
    from javascript import console
    times = []
    for _i in range(iterations):
        console.log("iteration: %s" % _i)
        t0 = time.time()
        # 40 calls
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        t1 = time.time()
        times.append(t1 - t0)
    return times
コード例 #13
0
def test_calls(iterations):
    from javascript import console
    times = []
    for _i in range(iterations):
        console.log("iteration: %s" % _i)
        t0 = time.time()
        # 40 calls
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        foo(1, 2, 3, 4)
        t1 = time.time()
        times.append(t1 - t0)
    return times
コード例 #14
0
 def err_msg(*args):
     from javascript import console
     console.log(args)