Пример #1
0
        def do_GET(self):
            # Parse query string, make sure we have a callback.
            url = urlparse(self.path)
            if '.jsonp' != url.path[-6:]: return SimpleHTTPRequestHandler.do_GET(self)
            query = parse_qs(url.query)
            if 'callback' not in query: raise Exception('No callback specified')
            callback = query['callback'][-1]

            # Get data for different JSONp calls
            try:
                if '/colorvalue.jsonp' == url.path:
                    data = color.colorvalue(query['colordef'][0], query['txo[]'])
                elif '/makeconversion.jsonp' == url.path:
                    data = color.makeconversion(loads(query['txspec'][0]))
                elif '/receive.jsonp' == url.path:
                    data = message.receive()
                elif '/send.jsonp' == url.path:
                    data = message.send(query['subject'][0], query['body'][0])
                elif '/signrawtransaction.jsonp' == url.path:
                    data = bitcoin.signrawtransaction(
                        query['rawtx'][0],
                        loads(query['inputs'][0]),
                        query['keys[]']
                    )
                else:
                    data = {'error': 'Did not understand ' + url.path}

            except (KeyError, ValueError): data = {'error': 'Wrong parameters', 'query': query}

            # Send the reply as jsonp
            self.send_response(200)
            self.send_header('Content-type', 'application/javascript')
            self.end_headers()
            self.wfile.write(bytes(callback + '(' + dumps(data) + ');', 'UTF-8'))
Пример #2
0
import message

OLDBAUD = 9600

print "Setting NAV5 config to airborne mode..."
navconfig = message.UBXMessage('CFG-NAV5', "\x01\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
(ack, null) = message.send(navconfig, baudrate=OLDBAUD)
if ack:
    print "ACK: ", ack.emit()
else:
    print "Didn't get ACK."

print "\nSaving settings to flash..."
(ack, null) = message.send(message.UBXSaveConfig(), OLDBAUD)
if ack:
    print "ACK: ", ack.emit()
else:
    print "Didn't get ACK."
    
print "Verifying NAV settings..."
(settings, ack) = message.send(message.UBXPollNav5(), OLDBAUD)
print "New settings: ", settings.payload
Пример #3
0
    for k, v in result.iteritems():
        print '%s : %s' % (k, v)

is_success, result = auth.get_access_token(CorpID, secret)
access_token = result.get('access_token')

# department
# is_success, result = department.get_department_list(access_token)
# print_dict(result)

# message
touser = '******'
toparty = '1868210'
# send_type = 'text'
# content = {'content': 'dingding'}

send_type = 'image'
content = {'media_id': '@lADOAMnd1M0Bqc0CgA'}
is_success, result = message.send(access_token, touser, toparty,
                                  send_type, content)
print result


# media
# media_type = 'image'
# media_file = open('./picture_test.jpg', 'rb')
# is_success, result = media.upload_media(access_token, media_type, media_file)
# print result

# picture_media_id = '@lADOAMnd1M0Bqc0CgA'
Пример #4
0
import message

OLDBAUD = 9600
NEWBAUD = 4800

print "Setting NAV5 config to airborne mode..."
navconfig = message.UBXMessage('CFG-NAV5', "\x01\x00\x07\x03\x00\x00\x00\x00\x10'\x00\x00\x05\x00\xfa\x00\xfa\x00d\x00,\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
(ack, null) = message.send(navconfig, baudrate=OLDBAUD)
if ack:
    print "ACK: ", ack.emit()
else:
    print "Didn't get ACK."

print "\nSetting GLL message rate to 0.."
glloff = message.NMEA_SetRateMsg('GLL', 0)
message.send(glloff, baudrate=OLDBAUD)
print "Done." # NMEA messages don't get ACK'd

print "\nSetting NEWBAUD rate to %d..." % NEWBAUD
print "Port 1"
setbaudmsg = message.NMEA_SetBaudMessage(1, NEWBAUD)
message.send(setbaudmsg, OLDBAUD)
print "Port 2"
setbaudmsg = message.NMEA_SetBaudMessage(2, NEWBAUD)
message.send(setbaudmsg, baudrate=OLDBAUD)
print "Done."

print "\nSaving settings to flash..."
(ack, null) = message.send(message.UBXSaveConfig(), OLDBAUD)
(ack, null) = message.send(message.UBXSaveConfig(), NEWBAUD)
if ack:
Пример #5
0
import message


print "Setting NAV5 config to airborne mode..."
navconfig = message.UBXMessage(
    "CFG-NAV5",
    "\x01\x00\x07\x03\x00\x00\x00\x00\x10'\x00\x00\x05\x00\xfa\x00\xfa\x00d\x00,\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
)
(ack, null) = message.send(navconfig)
if ack:
    print "ACK: ", ack.emit()
else:
    print "Didn't get ACK."

print "\nSetting GLL message rate to 0.."
glloff = message.NMEA_SetRateMsg("GLL", 0)
message.send(glloff)
print "Done."  # NMEA messages don't get ACK'd

print "\nSaving settings to flash..."
(ack, null) = message.send(message.UBXSaveConfig())
if ack:
    print "ACK: ", ack.emit()
else:
    print "Didn't get ACK."

print "Verifying NAV settings..."
(settings, ack) = message.send(message.UBXPollNav5())
print "New settings: ", settings.payload