LoginSignup
2
1

More than 1 year has passed since last update.

python実行で「bot error」

Posted at

はじめに

A-people見ていて少し気になったネタです。

pythonスクリプト単体は問題なく動くけど、A360から実行したら「bot error」になる話。

以下、簡略化したBotと結果の再現。

import base64

def ConvertText(data):
    datatoReturn = base64.b64encode(bytes(data,'utf-8'))
    return datatoReturn

python_bot.png

bot_error.png

ログを見てみる

「bot error」では原因がわからないので、ログを見てみます。
C:\ProgramData\AutomationAnywhere\BotRunner\Logs\Bot_Launcher.log

時刻を頼りに該当行を探してみると以下のエラーが出ているようです。
(適当に折り返しています)

encoder.py", line 179, in default     
raise TypeError(f'Object of type {o.__class__.__name__} ' 
TypeError: Object of type bytes is not JSON serializable 

base64.b64encodeはbytesオブジェクトを返すので、戻りを受け取る事ができないのだな、って事で、pythonスクリプトを以下修正。

datatoReturn = str(base64.b64encode(bytes(data,'utf-8')))

bytesオブジェクトを文字列に変換しておきます。
これで「bot error」を回避できました。
(他にいろいろやり方あると思います)

簡単なまとめ

「bot error」だけで原因がよくわからないときは、
C:\ProgramData\AutomationAnywhere\BotRunner\Logs\Bot_Launcher.log
を見てみましょう。

2
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1