質問編集履歴
2
更新
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Python Heroku
|
1
|
+
Python Heroku Lチカ
|
test
CHANGED
@@ -55,129 +55,3 @@
|
|
55
55
|
LINEから「点灯」または「消灯」と送信すると、LEDが「点灯」または「消灯」しますが、
|
56
56
|
|
57
57
|
このときにエラーが発生してしまいます。「点灯」と送った時のログは、次の通りです。
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
**今回の構成 Raspberry pi ⇔ Heroku ⇔ LINE**で、
|
62
|
-
|
63
|
-
LINEから、Raspberry piのGPIOを動作させることは不可能なのでしょうか。
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
```text
|
68
|
-
|
69
|
-
2020-01-06T03:36:05.095931+00:00 app[web.1]: Traceback (most recent call last):
|
70
|
-
|
71
|
-
2020-01-06T03:36:05.097434+00:00 app[web.1]: File "LED_ON.py", line 10, in <module>
|
72
|
-
|
73
|
-
2020-01-06T03:36:05.097499+00:00 app[web.1]: import RPi.GPIO as GPIO
|
74
|
-
|
75
|
-
2020-01-06T03:36:05.097530+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
|
76
|
-
|
77
|
-
2020-01-06T03:36:05.097781+00:00 app[web.1]: from RPi._GPIO import *
|
78
|
-
|
79
|
-
2020-01-06T03:36:05.097871+00:00 app[web.1]: RuntimeError: This module can only be run on a Raspberry Pi!
|
80
|
-
|
81
|
-
2020-01-06T03:36:05.107940+00:00 app[web.1]: [2020-01-06 03:36:05,107] ERROR in app: Exception on /callback [POST]
|
82
|
-
|
83
|
-
2020-01-06T03:36:05.107944+00:00 app[web.1]: Traceback (most recent call last):
|
84
|
-
|
85
|
-
2020-01-06T03:36:05.107946+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
|
86
|
-
|
87
|
-
2020-01-06T03:36:05.107949+00:00 app[web.1]: response = self.full_dispatch_request()
|
88
|
-
|
89
|
-
2020-01-06T03:36:05.107952+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
|
90
|
-
|
91
|
-
2020-01-06T03:36:05.107954+00:00 app[web.1]: rv = self.handle_user_exception(e)
|
92
|
-
|
93
|
-
2020-01-06T03:36:05.107955+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
|
94
|
-
|
95
|
-
2020-01-06T03:36:05.107958+00:00 app[web.1]: reraise(exc_type, exc_value, tb)
|
96
|
-
|
97
|
-
2020-01-06T03:36:05.107960+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
|
98
|
-
|
99
|
-
2020-01-06T03:36:05.107962+00:00 app[web.1]: rv = self.dispatch_request()
|
100
|
-
|
101
|
-
2020-01-06T03:36:05.107964+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
|
102
|
-
|
103
|
-
2020-01-06T03:36:05.107967+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args)
|
104
|
-
|
105
|
-
2020-01-06T03:36:05.107969+00:00 app[web.1]: File "app.py", line 74, in callback
|
106
|
-
|
107
|
-
2020-01-06T03:36:05.107971+00:00 app[web.1]: handler.handle(body, signature)
|
108
|
-
|
109
|
-
2020-01-06T03:36:05.107973+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/linebot/webhook.py", line 260, in handle
|
110
|
-
|
111
|
-
2020-01-06T03:36:05.107975+00:00 app[web.1]: func(event)
|
112
|
-
|
113
|
-
2020-01-06T03:36:05.107977+00:00 app[web.1]: File "app.py", line 117, in handle_postback
|
114
|
-
|
115
|
-
2020-01-06T03:36:05.107979+00:00 app[web.1]: subprocess.check_call(['python','LED_ON.py'])
|
116
|
-
|
117
|
-
2020-01-06T03:36:05.107981+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/subprocess.py", line 190, in check_call
|
118
|
-
|
119
|
-
2020-01-06T03:36:05.107983+00:00 app[web.1]: raise CalledProcessError(retcode, cmd)
|
120
|
-
|
121
|
-
2020-01-06T03:36:05.107985+00:00 app[web.1]: CalledProcessError: Command '[u'python', u'LED_ON.py']' returned non-zero exit status 1
|
122
|
-
|
123
|
-
2020-01-06T03:36:05.109608+00:00 app[web.1]: 10.63.60.103 - - [06/Jan/2020 03:36:05] "POST /callback HTTP/1.1" 500 -
|
124
|
-
|
125
|
-
2020-01-06T03:36:05.114140+00:00 heroku[router]: at=info method=POST path="/callback" host=remote-plc.herokuapp.com request_id=219d1fa7-b0f5-48f3-b7f9-95188a6e2c53 fwd="147.92.149.169" dyno=web.1 connect=0ms service=93ms status=500 bytes=450 protocol=https
|
126
|
-
|
127
|
-
```
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
##プログラムコード(一部)
|
132
|
-
|
133
|
-
```python
|
134
|
-
|
135
|
-
@handler.add(PostbackEvent)
|
136
|
-
|
137
|
-
def handle_postback(event):
|
138
|
-
|
139
|
-
if event.postback.data == '点灯':
|
140
|
-
|
141
|
-
subprocess.check_call(['python','LpikaON.py'])
|
142
|
-
|
143
|
-
line_bot_api.reply_message(
|
144
|
-
|
145
|
-
event.reply_token, TextSendMessage(text='点灯しました。'))
|
146
|
-
|
147
|
-
elif event.postback.data == '消灯':
|
148
|
-
|
149
|
-
subprocess.check_call(['python','LpikaOFF.py'])
|
150
|
-
|
151
|
-
line_bot_api.reply_message(
|
152
|
-
|
153
|
-
event.reply_token, TextSendMessage(text='消灯しました。'))
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
if __name__ == "__main__":
|
160
|
-
|
161
|
-
arg_parser = ArgumentParser(
|
162
|
-
|
163
|
-
usage='Usage: python ' + __file__ + ' [--port <port>] [--help]'
|
164
|
-
|
165
|
-
)
|
166
|
-
|
167
|
-
arg_parser.add_argument('-p', '--port', default=8000, help='port')
|
168
|
-
|
169
|
-
arg_parser.add_argument('-d', '--debug', default=False, help='debug')
|
170
|
-
|
171
|
-
options = arg_parser.parse_args()
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
# create tmp dir for download content
|
176
|
-
|
177
|
-
make_static_tmp_dir()
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
app.run(debug=options.debug, port=options.port)
|
182
|
-
|
183
|
-
```
|
1
プログラムコードを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -125,3 +125,59 @@
|
|
125
125
|
2020-01-06T03:36:05.114140+00:00 heroku[router]: at=info method=POST path="/callback" host=remote-plc.herokuapp.com request_id=219d1fa7-b0f5-48f3-b7f9-95188a6e2c53 fwd="147.92.149.169" dyno=web.1 connect=0ms service=93ms status=500 bytes=450 protocol=https
|
126
126
|
|
127
127
|
```
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
##プログラムコード(一部)
|
132
|
+
|
133
|
+
```python
|
134
|
+
|
135
|
+
@handler.add(PostbackEvent)
|
136
|
+
|
137
|
+
def handle_postback(event):
|
138
|
+
|
139
|
+
if event.postback.data == '点灯':
|
140
|
+
|
141
|
+
subprocess.check_call(['python','LpikaON.py'])
|
142
|
+
|
143
|
+
line_bot_api.reply_message(
|
144
|
+
|
145
|
+
event.reply_token, TextSendMessage(text='点灯しました。'))
|
146
|
+
|
147
|
+
elif event.postback.data == '消灯':
|
148
|
+
|
149
|
+
subprocess.check_call(['python','LpikaOFF.py'])
|
150
|
+
|
151
|
+
line_bot_api.reply_message(
|
152
|
+
|
153
|
+
event.reply_token, TextSendMessage(text='消灯しました。'))
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
if __name__ == "__main__":
|
160
|
+
|
161
|
+
arg_parser = ArgumentParser(
|
162
|
+
|
163
|
+
usage='Usage: python ' + __file__ + ' [--port <port>] [--help]'
|
164
|
+
|
165
|
+
)
|
166
|
+
|
167
|
+
arg_parser.add_argument('-p', '--port', default=8000, help='port')
|
168
|
+
|
169
|
+
arg_parser.add_argument('-d', '--debug', default=False, help='debug')
|
170
|
+
|
171
|
+
options = arg_parser.parse_args()
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
# create tmp dir for download content
|
176
|
+
|
177
|
+
make_static_tmp_dir()
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
app.run(debug=options.debug, port=options.port)
|
182
|
+
|
183
|
+
```
|