从Flask应用程序运行Shell脚本时推送完整文件

时间:2019-06-17 19:16:07

标签: python git github flask

要部署的文件大小为:78KB

已创建deploy.sh文件,当我直接在终端上运行该文件时,它将按原样推送该文件。但是,当我从Flask应用程序运行相同的脚本时,它只推送72KB(或乘以8)及其文件的跳过部分。

cd <PATH TO REPOSITORY PATH>
git add directory/* --force
git pull
git commit -m "updated from bash"
git push

python script

def push_from_local():
    os.system("./commit.sh")

1 个答案:

答案 0 :(得分:0)

已解决。我尝试在写入文件时运行命令,这就是发生问题的原因

我使用的方法错误

with open(config_file_name, 'w') as outfile:
        print("Writing to file")
        json.dump(req, outfile, indent=4)
        print("Config file is ready for push")

        github_util.push_new_file_to_github(config_file_name,"DatacloudIntl/dcapi","master","config/column_maps/"+domain_name+".json", False)

以此替换,并且可以工作。...

with open(config_file_name, 'w') as outfile:
        print("Writing to file")
        json.dump(req, outfile, indent=4)
        print("Config file is ready for push")

    github_util.push_new_file_to_github(config_file_name,"DatacloudIntl/dcapi","master","config/column_maps/"+domain_name+".json", False)