Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nlsdn
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
safeedge
nlsdn
Commits
c9d88965
Commit
c9d88965
authored
Apr 19, 2019
by
David Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bugs with database file handling.
parent
86cd96d1
Pipeline
#3008
passed with stages
in 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
src/nlsdn/server/config.py
src/nlsdn/server/config.py
+6
-1
src/nlsdn/server/sdn.py
src/nlsdn/server/sdn.py
+10
-8
No files found.
src/nlsdn/server/config.py
View file @
c9d88965
...
...
@@ -279,8 +279,13 @@ class NlSdnConfig(ConfigSection):
self
.
dbfile
=
jsonblob
[
"dbfile"
]
else
:
self
.
dbfile
=
"/var/lib/nlsdn/db.json"
if
not
os
.
access
(
self
.
dbfile
,
os
.
W_OK
|
os
.
R_OK
):
if
os
.
path
.
exists
(
self
.
dbfile
)
\
and
not
os
.
access
(
self
.
dbfile
,
os
.
W_OK
|
os
.
R_OK
):
raise
ConfigError
(
"cannot read/write nlsdn dbfile '
%
s'"
%
(
self
.
dbfile
,))
elif
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
self
.
dbfile
))
\
or
not
os
.
access
(
os
.
path
.
dirname
(
self
.
dbfile
),
os
.
W_OK
|
os
.
R_OK
):
raise
ConfigError
(
"cannot read/write nlsdn dbfile dir '
%
s'"
%
(
os
.
path
.
dirname
(
self
.
dbfile
),))
pass
pass
src/nlsdn/server/sdn.py
View file @
c9d88965
import
os
import
sys
import
json
from
nlsdn.util
import
CustomJsonEncoder
...
...
@@ -232,15 +233,16 @@ class Engine(object):
def
load
(
self
,
force
=
False
,
ensure
=
True
):
if
self
.
_loaded
and
not
force
:
return
fd
=
file
(
self
.
path
,
'r'
)
return
raw
=
""
while
True
:
x
=
fd
.
read
()
if
not
x
:
break
raw
+=
x
fd
.
close
()
if
os
.
path
.
exists
(
self
.
path
):
fd
=
file
(
self
.
path
,
'r'
)
while
True
:
x
=
fd
.
read
()
if
not
x
:
break
raw
+=
x
fd
.
close
()
rdb
=
{}
if
raw
!=
""
:
rdb
=
json
.
loads
(
raw
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment