-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimportData.py
More file actions
67 lines (52 loc) · 2.13 KB
/
importData.py
File metadata and controls
67 lines (52 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# coding: utf-8
# Copyright (C) 2017 Open Path View, Maison Du Libre
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
# Contributors: Simon Archieri <simon.archieri@openpathview.fr>
# Email: team@openpathview.fr
# Description: OPV status api
import os
import copy
import logging
from opv_status_api.importData.importDataThread import ImportDataThread
class ImportData:
logger = logging.getLogger("opv_status_api")
defaultLogFile = "/tmp/importData.log"
importDataThread = ImportDataThread()
def getStatus(self):
return {
"answer": self.importDataThread.getInfo(),
"error": None
}
def launchImport(self, data):
output = {
"answer": None,
"error": None
}
if "path" in data and "id_malette" in data and "camera_number" in data and "description" in data and "campaign_name" in data and "id_rederbro" in data:
self.importDataThread = ImportDataThread(data=data)
self.importDataThread.start()
output["answer"] = "Launched, you should check status to know if it work"
else:
output["error"] = "Missing param"
return output
def getLog(self, data):
output = {
"answer": None,
"error": None
}
logFile = self.defaultLogFile if "logFile" not in data else data["logFile"]
if os.path.isfile(logFile):
with open(logFile) as log:
output["answer"] = log.read()
else:
output["error"] = "Log file not found"
return output