Example #1
0
    def testWritingToJSON(self):
        writing = self._getWriting()

        expected = {u'width': 1000, u'height': 1000, u'strokes': [{u'points':
[{u'y': 2, u'timestamp': 3, u'x': 1}, {u'y': 5, u'pressure': 0, u'x': 4}]}]}

        self.assertEquals(minjson.read(writing.to_json()), expected)
Example #2
0
    def testCharacterToJSON(self):
        char = self._getCharacter()

        expected = {
            u'utf8': u'A',
            u'writing': {
                u'width':
                1000,
                u'height':
                1000,
                'strokes': [{
                    u'points': [{
                        u'y': 2,
                        u'timestamp': 3,
                        u'x': 1
                    }, {
                        u'y': 5,
                        u'pressure': 0,
                        u'x': 4
                    }]
                }]
            }
        }

        self.assertEquals(minjson.read(char.to_json()), expected)
Example #3
0
def handle_put(conversation):
	# See comment in handle_post()

	update = json.read(conversation.entity.text)
	set_state(update)

	return handle_get(conversation)
Example #4
0
 def testPointToJSON(self):
     point = self._getPoint()
     self.assertEquals(minjson.read(point.to_json()), {
         u'y': 2,
         u'timestamp': 3,
         u'x': 1
     })
Example #5
0
    def testStrokeToJSON(self):
        stroke = self._getStroke()

        expected = {u'points': [{u'y': 2, u'timestamp': 3, u'x': 1}, {u'y': 5,
u'pressure': 0, u'x': 4}]}

        self.assertEquals(minjson.read(stroke.to_json()), expected)
Example #6
0
    def testCharacterToJSON(self):
        char = self._getCharacter()

        expected = {u'utf8': u'A', u'writing': {u'width' : 1000, 
                    u'height': 1000, 'strokes': [{u'points': [{u'y':
                    2, u'timestamp': 3, u'x': 1}, 
                    {u'y': 5, u'pressure': 0, u'x': 4}]}]}}

        self.assertEquals(minjson.read(char.to_json()), expected)
Example #7
0
	def get_tc_calc(self):
		if self.edl:
			edl_fp = open(self.edl.path, 'r')
			edl = minjson.read(edl_fp.read()[10:])
			edl_fp.close()
			return tc.TcCalc(edl=edl)
			#if self.display_timecode == 'SRC':
			#	return tc.TcCalc(edl=edl)
			#return tc.TcCalc(start_tc=edl[0]['seqin'])
		return tc.TcCalc(start_tc=self.starttc)
Example #8
0
    def testStrokeToJSON(self):
        stroke = self._getStroke()

        expected = {
            u'points': [{
                u'y': 2,
                u'timestamp': 3,
                u'x': 1
            }, {
                u'y': 5,
                u'pressure': 0,
                u'x': 4
            }]
        }

        self.assertEquals(minjson.read(stroke.to_json()), expected)
Example #9
0
def handle_post(conversation):
	# Note that we are using the minjson library to parse the entity. While
	# a simple eval() would also work, minjson.read() is safer.

	update = json.read(conversation.entity.text)
	state_lock = get_state_lock()
	state = get_state()

	# Update our state
	state_lock.writeLock().lock()
	try:
		for key in update:
			state[key] = update[key]
	finally:
		state_lock.writeLock().unlock()

	return handle_get(conversation)
Example #10
0
def handle_put(conversation):
    # Note: You can only "consume" the entity once, so if we want it
    # as text, and want to refer to it more than once, we should keep
    # a reference to that text.

    text = conversation.entity.text
    note_dict = json.read(text)
    note = Note.create_from_dict(note_dict)

    session = get_session(application)
    try:
        session.add(note)
        update_board_timestamp(session, note)
        session.flush()
    finally:
        session.close()

    return handle_get(conversation)
Example #11
0
def handle_put(conversation):
    # Note: You can only "consume" the entity once, so if we want it
    # as text, and want to refer to it more than once, we should keep
    # a reference to that text.
    
    text = conversation.entity.text
    note_dict = json.read(text)
    note = Note.create_from_dict(note_dict)
    
    session = get_session(application)
    try:
        session.add(note)
        update_board_timestamp(session, note)
        session.flush()
    finally:
        session.close()
    
    return handle_get(conversation)
Example #12
0
    def testWritingToJSON(self):
        writing = self._getWriting()

        expected = {
            u'width':
            1000,
            u'height':
            1000,
            u'strokes': [{
                u'points': [{
                    u'y': 2,
                    u'timestamp': 3,
                    u'x': 1
                }, {
                    u'y': 5,
                    u'pressure': 0,
                    u'x': 4
                }]
            }]
        }

        self.assertEquals(minjson.read(writing.to_json()), expected)
Example #13
0
def handle_post(conversation):
    id = get_id(conversation)

    # Note: You can only "consume" the entity once, so if we want it
    # as text, and want to refer to it more than once, we should keep
    # a reference to that text.
    
    text = conversation.entity.text
    note_dict = json.read(text)

    session = get_session(application)
    try:
        note = session.query(Note).filter_by(id=id).one()
        note.update(note_dict)
        update_board_timestamp(session, note)
        session.flush()
    except NoResultFound:
        return 404
    finally:
        session.close()

    conversation.modificationTimestamp = datetime_to_milliseconds(note.timestamp)
    return json.write(note.to_dict())
Example #14
0
def handle_post(conversation):
    id = get_id(conversation)

    # Note: You can only "consume" the entity once, so if we want it
    # as text, and want to refer to it more than once, we should keep
    # a reference to that text.

    text = conversation.entity.text
    note_dict = json.read(text)

    session = get_session(application)
    try:
        note = session.query(Note).filter_by(id=id).one()
        note.update(note_dict)
        update_board_timestamp(session, note)
        session.flush()
    except NoResultFound:
        return 404
    finally:
        session.close()

    conversation.modificationTimestamp = datetime_to_milliseconds(
        note.timestamp)
    return json.write(note.to_dict())
Example #15
0
        self.mainLogger.debug('doChecks: payload: %s' % checksData)
        self.mainLogger.debug('doChecks: payloads built, convert to json')

        # Post back the data
        if int(pythonVersion[1]) >= 6:
            self.mainLogger.debug('doChecks: json convert')

            payload = json.dumps(checksData)
            testobj = json.loads(payload)

        else:
            self.mainLogger.debug('doChecks: minjson convert')

            payload = minjson.write(checksData)
            testobj = minjson.read(payload)

        self.mainLogger.debug('doChecks: json converted, hash')

        payloadHash = md5(payload).hexdigest()
        postBackData = urllib.urlencode({'payload': payload, 'hash': payloadHash})

        self.mainLogger.debug('doChecks: hashed, doPostBack')

        self.doPostBack(postBackData)

        self.mainLogger.debug('doChecks: posted back, reschedule')

        sc.enter(self.botConfig['checkFreq'], 1, self.doChecks, (sc, False))

    def getMountedLinuxProcFsLocation(self):
Example #16
0
def bang():
    x = minjson.read(PATCHER)
    print x
Example #17
0
 def testPointToJSON(self):
     point = self._getPoint()
     self.assertEquals(minjson.read(point.to_json()),
                       {u'y': 2, u'timestamp': 3, u'x': 1})