Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
cf9e9826
Commit
cf9e9826
authored
Oct 19, 2015
by
eric pellegrini
Browse files
Removed LOGGER called from the kernel
Bug fix with Preferences
parent
19e47fa0
Changes
6
Hide whitespace changes
Inline
Side-by-side
MDANSE/Core/Preferences.py
View file @
cf9e9826
...
...
@@ -35,7 +35,6 @@ import collections
import
ConfigParser
import
os
from
MDANSE
import
LOGGER
from
MDANSE.Core.Platform
import
PLATFORM
,
PlatformError
from
MDANSE.Core.Error
import
Error
from
MDANSE.Core.Singleton
import
Singleton
...
...
@@ -232,7 +231,7 @@ class InputDirectory(PreferencesItem):
try
:
PLATFORM
.
create_directory
(
value
)
except
PlatformError
:
LOGGER
(
"
Invalid value for %r preferences item. Set the default value instead.
"
%
self
.
_name
,
"warning"
)
raise
PreferencesError
(
'
Invalid value for %r preferences item. Set the default value instead.
'
%
self
.
_name
)
self
.
_value
=
self
.
_default
else
:
self
.
_value
=
value
...
...
@@ -337,7 +336,10 @@ class Preferences(collections.OrderedDict):
for
s
in
self
.
_parser
.
sections
():
for
k
,
v
in
self
.
_parser
.
items
(
s
):
if
self
.
has_key
(
k
):
self
[
k
].
set_value
(
v
)
try
:
self
[
k
].
set_value
(
v
)
except
PreferencesError
:
continue
else
:
self
.
_parser
.
remove_option
(
s
,
k
)
if
not
self
.
_parser
.
items
(
s
):
...
...
MDANSE/Framework/Jobs/IJob.py
View file @
cf9e9826
...
...
@@ -40,7 +40,7 @@ import subprocess
import
sys
import
traceback
from
MDANSE
import
LOGGER
,
PLATFORM
,
REGISTRY
from
MDANSE
import
PLATFORM
,
REGISTRY
from
MDANSE.Core.Error
import
Error
from
MDANSE.Framework.Configurable
import
Configurable
from
MDANSE.Framework.Jobs.JobStatus
import
JobStatus
...
...
@@ -468,8 +468,7 @@ class IJob(Configurable):
def
save_template
(
cls
,
shortname
,
classname
):
if
REGISTRY
[
'job'
].
has_key
(
shortname
):
LOGGER
(
'A job with %r name is already stored in the registry'
%
shortname
,
'error'
)
return
None
raise
KeyError
(
'A job with %r name is already stored in the registry'
%
shortname
)
from
MDANSE
import
PREFERENCES
macrosDir
=
PREFERENCES
[
"macros_directory"
].
get_value
()
...
...
@@ -545,7 +544,6 @@ class %s(IJob):
'''
%
(
classname
,
shortname
,
classname
))
except
IOError
:
LOGGER
(
'The job template could not be save to %r. Maybe a permission problem.'
%
templateFile
,
'error'
)
return
None
else
:
f
.
close
()
...
...
MDANSE/GUI/JobTemplateEditor.py
View file @
cf9e9826
...
...
@@ -101,12 +101,15 @@ class JobTemplateEditor(wx.Dialog):
return
from
MDANSE.Framework.Jobs.IJob
import
IJob
filename
=
IJob
.
save_template
(
shortName
,
className
)
if
filename
is
not
None
:
LOGGER
(
'Job template successfully saved to %r.'
%
filename
,
'info'
,[
'console'
])
self
.
EndModal
(
wx
.
ID_OK
)
try
:
filename
=
IJob
.
save_template
(
shortName
,
className
)
except
(
IOError
,
KeyError
)
as
e
:
LOGGER
(
str
(
e
),
'error'
,[
'console'
])
return
LOGGER
(
'Job template successfully saved to %r.'
%
filename
,
'info'
,[
'console'
])
self
.
EndModal
(
wx
.
ID_OK
)
if
__name__
==
"__main__"
:
app
=
wx
.
App
(
False
)
...
...
MDANSE/GUI/PreferencesSettings.py
View file @
cf9e9826
...
...
@@ -37,7 +37,8 @@ import wx
import
wx.aui
as
wxaui
import
wx.lib.filebrowsebutton
as
wxfile
from
MDANSE
import
PLATFORM
,
PREFERENCES
from
MDANSE
import
LOGGER
,
PLATFORM
,
PREFERENCES
from
MDANSE.Core.Preferences
import
PreferencesError
class
WritableDirectoryValidator
(
wx
.
PyValidator
):
...
...
@@ -187,21 +188,27 @@ class PreferencesSettings(wx.Dialog):
return
True
def
on_apply
(
self
,
event
):
def
on_apply
(
self
,
event
=
None
):
if
not
self
.
validate
():
return
return
False
valid
=
True
for
k
,
widget
in
self
.
_widgets
.
items
():
PREFERENCES
[
k
].
set_value
(
widget
.
get_value
())
try
:
PREFERENCES
[
k
].
set_value
(
widget
.
get_value
())
except
PreferencesError
as
e
:
LOGGER
(
str
(
e
),
'error'
,[
'console'
])
valid
=
False
continue
return
valid
def
on_ok
(
self
,
event
):
if
not
self
.
validate
():
if
not
self
.
on_apply
():
return
for
k
,
widget
in
self
.
_widgets
.
items
():
PREFERENCES
[
k
].
set_value
(
widget
.
get_value
())
PREFERENCES
.
save
()
...
...
MDANSE/__init__.py
View file @
cf9e9826
...
...
@@ -79,7 +79,6 @@ def databasePath(filename, directory, try_direct = False):
if
entries
is
None
:
if
directory
==
"Atoms"
:
LOGGER
(
"Atom %r not found in the MMTK database. MDANSE will create a default one."
%
basename
,
"warning"
)
ELEMENTS
.
add_element
(
basename
,
save
=
True
)
return
os
.
path
.
join
(
PLATFORM
.
local_mmtk_database_directory
(),
"Atoms"
,
basename
)
else
:
...
...
Scripts/mdanse
View file @
cf9e9826
...
...
@@ -8,6 +8,7 @@ import subprocess
import
sys
import
textwrap
from
MDANSE
import
LOGGER
from
MDANSE.Core.Error
import
Error
from
MDANSE
import
ELEMENTS
,
PLATFORM
,
REGISTRY
from
MDANSE.Framework.Jobs.JobStatus
import
JobState
...
...
@@ -70,9 +71,7 @@ class CommandLineParser(optparse.OptionParser):
def
__init__
(
self
,
*
args
,
**
kwargs
):
optparse
.
OptionParser
.
__init__
(
self
,
*
args
,
**
kwargs
)
from
MDANSE
import
LOGGER
LOGGER
.
add_handler
(
"terminal"
,
REGISTRY
[
'handler'
][
'terminal'
](),
level
=
"info"
,
start
=
True
)
LOGGER
.
start
()
...
...
@@ -337,9 +336,13 @@ class CommandLineParser(optparse.OptionParser):
raise
CommandLineParserError
(
"Invalid number of arguments for %r option"
%
opt_str
)
shortname
,
classname
=
parser
.
rargs
IJob
.
save_template
(
shortname
,
classname
)
try
:
IJob
.
save_template
(
shortname
,
classname
)
except
(
IOError
,
KeyError
)
as
e
:
LOGGER
(
str
(
e
),
'error'
,[
'console'
])
return
if
__name__
==
"__main__"
:
from
MDANSE.__pkginfo__
import
__version__
,
__date__
...
...
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