Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
neoppod
Commits
f2babb12
Commit
f2babb12
authored
Oct 02, 2015
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand ~(user) construction for all paths in configuration
Before, it was only done for 'logfile'.
parent
57481c35
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
7 deletions
+13
-7
neo.conf
neo.conf
+4
-1
neo/lib/config.py
neo/lib/config.py
+1
-1
neo/storage/database/importer.py
neo/storage/database/importer.py
+2
-1
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+4
-3
neo/storage/database/sqlite.py
neo/storage/database/sqlite.py
+2
-1
No files found.
neo.conf
View file @
f2babb12
...
@@ -5,6 +5,9 @@
...
@@ -5,6 +5,9 @@
# See SafeConfigParser at https://docs.python.org/2/library/configparser.html
# See SafeConfigParser at https://docs.python.org/2/library/configparser.html
# for more information about the syntax.
# for more information about the syntax.
# ~ and ~user constructions are expanded for all paths, even for those that
# may appear in 'database' option.
# Common parameters.
# Common parameters.
[
DEFAULT
]
[
DEFAULT
]
# The cluster name
# The cluster name
...
@@ -54,7 +57,7 @@ partitions: 12
...
@@ -54,7 +57,7 @@ partitions: 12
[
admin
]
[
admin
]
bind
:
127
.
0
.
0
.
1
:
9999
bind
:
127
.
0
.
0
.
1
:
9999
# Paths to log files can be specified here, but be careful not to do it in a
# Paths to log files can be specified here, but be careful not to do it in a
# common section.
~ and ~user constructions are expanded.
# common section.
;
logfile
: ~/
log
/
admin
.
log
;
logfile
: ~/
log
/
admin
.
log
# Master nodes
# Master nodes
...
...
neo/lib/config.py
View file @
f2babb12
...
@@ -102,7 +102,7 @@ class ConfigurationManager(object):
...
@@ -102,7 +102,7 @@ class ConfigurationManager(object):
return
self
.
__get
(
'wait'
)
return
self
.
__get
(
'wait'
)
def
getDynamicMasterList
(
self
):
def
getDynamicMasterList
(
self
):
return
self
.
__get
(
'dynamic_master_list'
,
optional
=
True
)
return
self
.
__get
Path
(
'dynamic_master_list'
,
optional
=
True
)
def
getAdapter
(
self
):
def
getAdapter
(
self
):
return
self
.
__get
(
'adapter'
)
return
self
.
__get
(
'adapter'
)
...
...
neo/storage/database/importer.py
View file @
f2babb12
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
cPickle
,
pickle
,
time
import
cPickle
,
pickle
,
time
from
bisect
import
bisect
,
insort
from
bisect
import
bisect
,
insort
from
collections
import
deque
from
collections
import
deque
...
@@ -286,7 +287,7 @@ class ImporterDatabaseManager(DatabaseManager):
...
@@ -286,7 +287,7 @@ class ImporterDatabaseManager(DatabaseManager):
def
_parse
(
self
,
database
):
def
_parse
(
self
,
database
):
config
=
SafeConfigParser
()
config
=
SafeConfigParser
()
config
.
read
(
database
)
config
.
read
(
os
.
path
.
expanduser
(
database
)
)
sections
=
config
.
sections
()
sections
=
config
.
sections
()
# XXX: defaults copy & pasted from elsewhere - refactoring needed
# XXX: defaults copy & pasted from elsewhere - refactoring needed
main
=
{
'adapter'
:
'MySQL'
,
'wait'
:
0
}
main
=
{
'adapter'
:
'MySQL'
,
'wait'
:
0
}
...
...
neo/storage/database/mysqldb.py
View file @
f2babb12
...
@@ -21,6 +21,7 @@ from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST
...
@@ -21,6 +21,7 @@ from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST
from
MySQLdb.constants.ER
import
DATA_TOO_LONG
,
DUP_ENTRY
from
MySQLdb.constants.ER
import
DATA_TOO_LONG
,
DUP_ENTRY
from
array
import
array
from
array
import
array
from
hashlib
import
sha1
from
hashlib
import
sha1
import
os
import
re
import
re
import
string
import
string
import
struct
import
struct
...
@@ -57,9 +58,9 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -57,9 +58,9 @@ class MySQLDatabaseManager(DatabaseManager):
def
_parse
(
self
,
database
):
def
_parse
(
self
,
database
):
""" Get the database credentials (username, password, database) """
""" Get the database credentials (username, password, database) """
# expected pattern : [user[:password]@]database[(.|/)unix_socket]
# expected pattern : [user[:password]@]database[(
~|
.|/)unix_socket]
self
.
user
,
self
.
passwd
,
self
.
db
,
self
.
socket
=
re
.
match
(
self
.
user
,
self
.
passwd
,
self
.
db
,
self
.
socket
=
re
.
match
(
'(?:([^:]+)(?::(.*))?@)?([^./]+)(.+)?$'
,
database
).
groups
()
'(?:([^:]+)(?::(.*))?@)?([^
~
./]+)(.+)?$'
,
database
).
groups
()
def
close
(
self
):
def
close
(
self
):
self
.
conn
.
close
()
self
.
conn
.
close
()
...
@@ -69,7 +70,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -69,7 +70,7 @@ class MySQLDatabaseManager(DatabaseManager):
if
self
.
passwd
is
not
None
:
if
self
.
passwd
is
not
None
:
kwd
[
'passwd'
]
=
self
.
passwd
kwd
[
'passwd'
]
=
self
.
passwd
if
self
.
socket
:
if
self
.
socket
:
kwd
[
'unix_socket'
]
=
self
.
socket
kwd
[
'unix_socket'
]
=
os
.
path
.
expanduser
(
self
.
socket
)
logging
.
info
(
'connecting to MySQL on the database %s with user %s'
,
logging
.
info
(
'connecting to MySQL on the database %s with user %s'
,
self
.
db
,
self
.
user
)
self
.
db
,
self
.
user
)
if
self
.
_wait
<
0
:
if
self
.
_wait
<
0
:
...
...
neo/storage/database/sqlite.py
View file @
f2babb12
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
sqlite3
import
sqlite3
from
hashlib
import
sha1
from
hashlib
import
sha1
import
string
import
string
...
@@ -70,7 +71,7 @@ class SQLiteDatabaseManager(DatabaseManager):
...
@@ -70,7 +71,7 @@ class SQLiteDatabaseManager(DatabaseManager):
self
.
_connect
()
self
.
_connect
()
def
_parse
(
self
,
database
):
def
_parse
(
self
,
database
):
self
.
db
=
database
self
.
db
=
os
.
path
.
expanduser
(
database
)
def
close
(
self
):
def
close
(
self
):
self
.
conn
.
close
()
self
.
conn
.
close
()
...
...
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