/
kintone.py
78 lines (67 loc) · 2.06 KB
/
kintone.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import pykintone
from pykintone import model
import json
import sys
import datetime
class Kintone(model.kintoneModel):
# アプリデータの取得
def appDataget(self):
# 受け取った引数でAPP接続先を変える
fileName = self.appName + '_account.yml'
try:
account = pykintone.load(fileName)
app = account.app()
result = app.select("flag = 0").records
return result
except Exception:
texta = "{}:アプリデータ取得に失敗\n"
dt = datetime.datetime.now()
with open("log.txt", "a") as fileobj:
text = texta.format(dt)
fileobj.write(text)
# 取引先配列生成
def getCustomerList(self):
customerList = {
"rt":"楽天市場",
"yh":"Yahoo!",
"st":"STORE",
"mn":""
}
return customerList
# 取引先名を取得
def getCustomerName(self):
customerList = self.getCustomerList()
customer = customerList[self.appName]
return customer
# insert
def insertOrderManagementAPP(self):
print(appDataList[0])
account = pykintone.load("test.yml")
app = account.app()
record = Kintone()
record.channel = "test6"
record.customer = "test7"
try:
app.create(record)
except Exception:
texta = "{}:受注管理表の更新に失敗\n"
dt = datetime.datetime.now()
with open("log.txt", "a") as fileobj:
text = texta.format(dt)
fileobj.write(text)
print('AAAAAAAaa')
pr = Kintone()
# 引数取得
arg = sys.argv
pr.appName = arg[1]
# データ取得
appDataList = pr.appDataget()
customer = pr.getCustomerName()
#insert
pr.insertOrderManagementAPP()
print('End')
#print("{}".format(json.dumps(appDataList[0],indent=4)))
#print(appDataList[0])
#print(appName)
#print("{}".format(json.dumps(appDataList[0],indent=4)))
#print(result[0]["rt_orderNumber"]["value"])