Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
8c876d7f
Commit
8c876d7f
authored
9 years ago
by
Leal, Ricardo
Browse files
Options
Downloads
Patches
Plain Diff
Re #13821 Added logger instead of print.
parent
2341d870
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/data_cat.py
+22
-10
22 additions, 10 deletions
...cripts/Interface/reduction_gui/reduction/sans/data_cat.py
with
22 additions
and
10 deletions
Code/Mantid/scripts/Interface/reduction_gui/reduction/sans/data_cat.py
+
22
−
10
View file @
8c876d7f
...
@@ -6,11 +6,19 @@
...
@@ -6,11 +6,19 @@
"""
"""
import
os
import
os
import
sqlite3
import
sqlite3
import
re
import
time
import
sys
import
sys
import
traceback
import
traceback
# Only way that I have found to use the logger from both the command line
# and mantiplot
try
:
import
mantidplot
from
mantid.kernel
import
logger
except
ImportError
:
import
logging
logging
.
basicConfig
()
#level=logging.DEBUG)
logger
=
logging
.
getLogger
(
"
data_cat
"
)
class
DataType
(
object
):
class
DataType
(
object
):
TABLE_NAME
=
"
datatype
"
TABLE_NAME
=
"
datatype
"
...
@@ -27,7 +35,8 @@ class DataType(object):
...
@@ -27,7 +35,8 @@ class DataType(object):
id integer primary key,
id integer primary key,
type_id integer,
type_id integer,
dataset_id integer,
dataset_id integer,
foreign key(dataset_id) references %s(id))
"""
%
(
cls
.
TABLE_NAME
,
data_set_table
))
foreign key(dataset_id) references %s(id))
"""
\
%
(
cls
.
TABLE_NAME
,
data_set_table
))
@classmethod
@classmethod
def
add
(
cls
,
dataset_id
,
type_id
,
cursor
):
def
add
(
cls
,
dataset_id
,
type_id
,
cursor
):
...
@@ -35,10 +44,11 @@ class DataType(object):
...
@@ -35,10 +44,11 @@ class DataType(object):
Add a data type entry to the datatype table
Add a data type entry to the datatype table
"""
"""
if
not
type_id
in
cls
.
DATA_TYPES
.
keys
():
if
not
type_id
in
cls
.
DATA_TYPES
.
keys
():
raise
RuntimeError
,
"
DataType got an unknown type ID: %s
"
%
type_id
raise
RuntimeError
(
"
DataType got an unknown type ID: %s
"
%
type_id
)
t
=
(
type_id
,
dataset_id
,)
t
=
(
type_id
,
dataset_id
,)
cursor
.
execute
(
"
insert into %s(type_id, dataset_id) values (?,?)
"
%
cls
.
TABLE_NAME
,
t
)
cursor
.
execute
(
"
insert into %s(type_id, dataset_id) values (?,?)
"
\
%
cls
.
TABLE_NAME
,
t
)
@classmethod
@classmethod
def
get_likely_type
(
cls
,
dataset_id
,
cursor
):
def
get_likely_type
(
cls
,
dataset_id
,
cursor
):
...
@@ -133,7 +143,7 @@ class DataSet(object):
...
@@ -133,7 +143,7 @@ class DataSet(object):
if
cls
.
load_meta_data
(
file_path
,
outputWorkspace
=
log_ws
):
if
cls
.
load_meta_data
(
file_path
,
outputWorkspace
=
log_ws
):
try
:
try
:
return
cls
.
read_properties
(
log_ws
,
run
,
cursor
)
return
cls
.
read_properties
(
log_ws
,
run
,
cursor
)
except
:
except
Exception
:
return
None
return
None
else
:
else
:
return
None
return
None
...
@@ -177,8 +187,9 @@ class DataCatalog(object):
...
@@ -177,8 +187,9 @@ class DataCatalog(object):
try
:
try
:
self
.
_create_db
(
db_path
,
replace_db
)
self
.
_create_db
(
db_path
,
replace_db
)
except
:
except
Exception
,
msg
:
print
"
DataCatalog: Could not access local data catalog
\n
%s
"
%
sys
.
exc_value
logger
.
error
(
"
DataCatalog: Could not access local data catalog
\n
%s
"
%
sys
.
exc_value
)
logger
.
exception
(
msg
)
def
_create_db
(
self
,
db_path
,
replace_db
):
def
_create_db
(
self
,
db_path
,
replace_db
):
"""
"""
...
@@ -278,5 +289,6 @@ class DataCatalog(object):
...
@@ -278,5 +289,6 @@ class DataCatalog(object):
self
.
db
.
commit
()
self
.
db
.
commit
()
c
.
close
()
c
.
close
()
except
:
except
Exception
,
msg
:
print
"
DataCatalog: Error working with the local data catalog
\n
%s
"
%
str
(
traceback
.
format_exc
())
logger
.
error
(
"
DataCatalog: Error working with the local data catalog
\n
%s
"
%
str
(
traceback
.
format_exc
()))
logger
.
exception
(
msg
)
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