コード例 #1
0
ファイル: remote_pi.py プロジェクト: sada-nishio/remote_pi
def main():
    #kintoneの認証情報
    domain = 'example.cybozu.com'
    token = ''
    app = 329
    query = 'flag in ("まだ!!")'

    #kinotoneに新規レコードが存在するかチェック
    try:
        kintone = Kintone()
        kintone.set_domain(domain)
        kintone.set_token_auth(token)
        response = kintone.get_records(app, query)
        records = response['records']
    except:
        print('Error: kintone.get_records is failed.')
        return 1
    #存在した場合、赤外線LEDでONを送信
    if (len(records) > 0):
        #lircを実行
        try:
            cmd = 'irsend SEND_ONCE aircon on'
            output = subprocess.check_output(cmd.strip().split(' '))
            print('Info: irsend Success!')
        except:
            print(output)
            print('Error: irsend Failed!')
            return 1

        #レコードのフラグを実行済みに更新
        record_num = records[0]['レコード番号']['value']
        try:
            record = {
                'flag': {
                    'value': '実行済!!'
                }
            }
            put_resp = kintone.put_record(app, record_num, record)
            print(put_resp)
        except:
            print('Error: kintone.put_record is failed.')
            return 1

        print('Info: success!!.')
        #正常終了
        return 0
    else:
        print('Info: no records.')
        return 0
コード例 #2
0
def main():
    #kintoneの認証情報
    domain = 'example.cybozu.com'
    token = ''
    app = 329
    query = 'flag in ("まだ!!")'

    #kinotoneに新規レコードが存在するかチェック
    try:
        kintone = Kintone()
        kintone.set_domain(domain)
        kintone.set_token_auth(token)
        response = kintone.get_records(app, query)
        records = response['records']
    except:
        print('Error: kintone.get_records is failed.')
        return 1
    #存在した場合、赤外線LEDでONを送信
    if (len(records) > 0):
        #lircを実行
        try:
            cmd = 'irsend SEND_ONCE aircon on'
            output = subprocess.check_output(cmd.strip().split(' '))
            print('Info: irsend Success!')
        except:
            print(output)
            print('Error: irsend Failed!')
            return 1

        #レコードのフラグを実行済みに更新
        record_num = records[0]['レコード番号']['value']
        try:
            record = {'flag': {'value': '実行済!!'}}
            put_resp = kintone.put_record(app, record_num, record)
            print(put_resp)
        except:
            print('Error: kintone.put_record is failed.')
            return 1

        print('Info: success!!.')
        #正常終了
        return 0
    else:
        print('Info: no records.')
        return 0
コード例 #3
0
                'value': 'change_title1'
            }
        }
    },
    {
        'id': 2,
        'record': {
            'title': {
                'value': 'change_title1'
            }
        }
    }
]
##Single Record
record_id = 1
put_record_resp = kintone.put_record(app_id, 1, put_record)
print(put_record_resp)
##Multi Records
put_records_resp = kintone.put_records(app_id, put_records)
print(put_records_resp)

#DELETE
record_ids = [1, 2, 3]
del_records_resp = kintone.delete_records(app_id, record_ids)
print(del_records_resp)

#Download File
file_path = './sample.png'
file_key = '20151128..........'
binary = kintone.download_file(file_key)
with open(file_path, 'rb') as f:
コード例 #4
0
    'record': {
        'title': {
            'value': 'change_title1'
        }
    }
}, {
    'id': 2,
    'record': {
        'title': {
            'value': 'change_title1'
        }
    }
}]
##Single Record
record_id = 1
put_record_resp = kintone.put_record(app_id, 1, put_record)
print(put_record_resp)
##Multi Records
put_records_resp = kintone.put_records(app_id, put_records)
print(put_records_resp)

#DELETE
record_ids = [1, 2, 3]
del_records_resp = kintone.delete_records(app_id, record_ids)
print(del_records_resp)

#Download File
file_path = './sample.png'
file_key = '20151128..........'
binary = kintone.download_file(file_key)
with open(file_path, 'rb') as f: