EOX GitLab Instance
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESA
PRISM
VS
Commits
81d5a1e1
Commit
81d5a1e1
authored
4 years ago
by
Mussab Abdalla
Browse files
Options
Downloads
Patches
Plain Diff
save/move xml
parent
cdb74e5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!55
Production release 1.2.0
,
!50
Ingestor status
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ingestor/app.py
+3
-3
3 additions, 3 deletions
ingestor/app.py
ingestor/filedaemon.py
+6
-9
6 additions, 9 deletions
ingestor/filedaemon.py
ingestor/ingestor/util.py
+8
-4
8 additions, 4 deletions
ingestor/ingestor/util.py
with
17 additions
and
16 deletions
ingestor/app.py
+
3
−
3
View file @
81d5a1e1
...
...
@@ -35,7 +35,7 @@ from flask import Flask, request, Response
import
redis
from
ingestor.browse_report
import
parse_browse_report
from
ingestor.util
import
converter
,
save_
json
,
browse_name
from
ingestor.util
import
converter
,
save_
report
,
browse_name
application
=
Flask
(
__name__
)
...
...
@@ -94,9 +94,9 @@ def ingest():
try
:
client
.
lpush
(
queue_name
,
queue_content
)
save_
json
(
filename
,
que
ue_content
,
True
)
save_
report
(
filename
,
re
que
st
.
data
,
True
)
return
Response
(
status
=
202
)
except
Exception
as
e
:
save_
json
(
filename
,
que
ue_content
,
False
)
save_
report
(
filename
,
re
que
st
.
data
,
False
)
return
Response
(
str
(
e
),
status
=
400
)
This diff is collapsed.
Click to expand it.
ingestor/filedaemon.py
+
6
−
9
View file @
81d5a1e1
...
...
@@ -35,7 +35,7 @@ import pyinotify
import
redis
from
ingestor.browse_report
import
parse_browse_report
from
ingestor.util
import
converter
,
save_
json
,
browse_name
from
ingestor.util
import
converter
,
save_
report
,
browse_name
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -83,27 +83,24 @@ watchmanager = pyinotify.WatchManager()
class
EventHandler
(
pyinotify
.
ProcessEvent
):
def
process_IN_CLOSE_WRITE
(
self
,
event
):
logger
.
info
(
f
'
Parsing browse file:
{
event
.
pathname
}
'
)
with
open
(
event
.
pathname
)
as
f
:
browse_report
=
parse_browse_report
(
f
)
logger
.
debug
(
browse_report
)
if
isinstance
(
browse_report
,
str
):
queue_content
=
browse_report
filename
=
queue_content
queue_content
=
event
.
pathname
else
:
queue_content
=
json
.
dumps
(
browse_report
,
default
=
converter
)
filename
=
browse_name
(
browse_report
)
try
:
client
.
lpush
(
queue_name
,
queue_content
)
save_
json
(
filename
,
queue_content
,
True
)
save_
report
(
''
,
event
.
pathname
,
True
)
except
Exception
as
e
:
save_
json
(
filename
,
queue_content
,
False
)
save_
report
(
''
,
event
.
pathname
,
False
)
logger
.
exception
(
e
)
handler
=
EventHandler
()
...
...
This diff is collapsed.
Click to expand it.
ingestor/ingestor/util.py
+
8
−
4
View file @
81d5a1e1
...
...
@@ -27,6 +27,7 @@
import
json
import
os
import
shutil
from
datetime
import
datetime
...
...
@@ -40,16 +41,19 @@ def converter(o):
if
isinstance
(
o
,
datetime
):
return
o
.
isoformat
()
def
save_json
(
filename
:
str
,
data
,
success
:
bool
):
def
save_report
(
filename
:
str
,
data
,
success
:
bool
):
if
success
:
save_dir
=
os
.
environ
[
'
INGESTOR_SUCCESS_DIR
'
]
else
:
save_dir
=
os
.
environ
[
'
INGESTOR_FAIL_DIR
'
]
with
open
(
"
%s/%s.json
"
%
(
save_dir
,
filename
),
"
w
"
)
as
outfile
:
outfile
.
write
(
data
)
if
isinstance
(
data
,
str
):
shutil
.
move
(
data
,
save_dir
)
else
:
with
open
(
os
.
path
.
join
(
save_dir
,
'
%s.xml
'
%
filename
),
"
w
"
)
as
outfile
:
outfile
.
write
(
data
)
def
browse_name
(
report
):
return
'
_
'
.
join
(
browse
[
"
browse_identifier
"
]
for
browse
in
report
[
"
browses
"
])
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment