そのため、1 日より新しいファイルをチェックするスクリプトがあります。今日作成されたように、このディレクトリに 1 日以内に作成されたファイルがない場合、スクリプトから電子メールが送信されるようにします。
私のスクリプトをお見せしましょう:
new_files = [] #list of files newer than 1 day
for f in os.listdir(path):
fn = os.path.join(path,f)
ctime = os.stat(fn).st_ctime
if ctime > now - 1 * 86400:
#this is a new file
new_files.append(fn)
if new_files(): #checks the list
sendmail #calls sendmail script that sends email
それで、if new_files():
リストに何かが追加されているかどうかを確認するためにリストをチェックしていますか?そうでない場合は、プロセスが失敗したため、発券システムに警告メールを生成して知る必要があります。これが私の問題です。リストの確認方法がわかりません。スクリプトを実行すると、TypeError: 'list' object is not callable
.
これを行う正しい方法は何ですか?