Commit 9eaeb2e4 by BoxuanXu

fix fdfs's bug

1 parent ba8c03a2
Showing with 26 additions and 20 deletions
...@@ -5,7 +5,8 @@ import pymysql.cursors ...@@ -5,7 +5,8 @@ import pymysql.cursors
import logging import logging
import subprocess import subprocess
from libpywrap import * #from libpywrap import *
from stbfclient import client
import requests import requests
...@@ -20,7 +21,7 @@ from mysql_glock import Mysql_lock ...@@ -20,7 +21,7 @@ from mysql_glock import Mysql_lock
import GProgress as GP import GProgress as GP
import Queue import Queue
import os
__website__ = "www.seetatech.com" __website__ = "www.seetatech.com"
__author__ = "seetatech" __author__ = "seetatech"
__editor__ = "xuboxuan" __editor__ = "xuboxuan"
...@@ -30,7 +31,8 @@ __Date__ = "20170807" ...@@ -30,7 +31,8 @@ __Date__ = "20170807"
app = Flask(__name__) app = Flask(__name__)
#initlization fdfs_client #initlization fdfs_client
stbf_stcnf("/etc/fdfs/client.conf") #stbf_stcnf("/etc/fdfs/client.conf")
client.set_conf("/etc/fdfs/client.conf")
download_path="." download_path="."
...@@ -121,18 +123,26 @@ def get_path_from_db(modelid,seetanet_model): ...@@ -121,18 +123,26 @@ def get_path_from_db(modelid,seetanet_model):
#download file from fastdfs #download file from fastdfs
if(stbf_down(params_name_path,download_path)): try:
logging.info("download params file: %s success" % params_name) client.down_file(params_name_path,download_path)
else: if os.path.exists(params_name):
err_msg = "download file failed" logging.info("download params file: %s success" % params_name)
return None,None,err_msg else:
raise Exception("raise exception")
except Exception, e:
err_msg = "download file failed"
return None,None,err_msg
#download file from fastdfs #download file from fastdfs
if(stbf_down(graph_name_path,download_path)): try:
logging.info("download params file: %s success" % graph_name) client.down_file(graph_name_path,download_path)
else: if os.path.exists(graph_name):
err_msg = "download file failed" logging.info("download params file: %s success" % graph_name)
return None,None,err_msg else:
raise Exception("raise exception")
except Exception, e:
err_msg = "download file failed"
return None,None,err_msg
#post return progress #post return progress
GP.set_progress_var(10) GP.set_progress_var(10)
GP.Post_return() GP.Post_return()
...@@ -149,7 +159,7 @@ def get_path_from_db(modelid,seetanet_model): ...@@ -149,7 +159,7 @@ def get_path_from_db(modelid,seetanet_model):
def upload_filetoFastDFS(params_name, graph_name,seetanet_model): def upload_filetoFastDFS(params_name, graph_name,seetanet_model):
#upload seetanet file to fastdfs #upload seetanet file to fastdfs
stmodel_fid = stbf_up(seetanet_model) stmodel_fid = client.up_file(seetanet_model)
if(stmodel_fid): if(stmodel_fid):
logging.info("upload seetanet file success,seetanet model_id is %s" % stmodel_fid) logging.info("upload seetanet file success,seetanet model_id is %s" % stmodel_fid)
else: else:
...@@ -298,9 +308,5 @@ def Dirver_Convert(): ...@@ -298,9 +308,5 @@ def Dirver_Convert():
if __name__ == '__main__': if __name__ == '__main__':
try: t.start();
t.start(); app.run(host='0.0.0.0')
app.run(host='0.0.0.0')
finally:
stbf_rls()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!