Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cfel_fmt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
dataAnalysis
cfel_fmt
Commits
ca5834e1
Commit
ca5834e1
authored
8 years ago
by
Valerio Mariani
Browse files
Options
Downloads
Plain Diff
Merge branch 'testing'
parents
a281d5ed
06e526ae
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cfel_fabio.py
+11
-11
11 additions, 11 deletions
cfel_fabio.py
cfel_optarg.py
+12
-9
12 additions, 9 deletions
cfel_optarg.py
with
23 additions
and
20 deletions
cfel_fabio.py
+
11
−
11
View file @
ca5834e1
...
...
@@ -51,24 +51,24 @@ def read_cbf_from_stream(stream):
infile
=
stream
cbf_obj
.
_readheader
(
infile
)
if
fabio
.
cbfimage
.
CIF_BINARY_BLOCK_KEY
not
in
cbf_obj
.
cif
:
err
=
"
Not key %s in CIF, no CBF image in stream
"
%
fabio
.
cbf
image
.
CIF_BINARY_BLOCK_KEY
if
cbf_obj
.
CIF_BINARY_BLOCK_KEY
not
in
cbf_obj
.
cif
:
err
=
"
Not key %s in CIF, no CBF image in stream
"
%
fabio
.
cbf
obj
.
CIF_BINARY_BLOCK_KEY
logger
.
error
(
err
)
for
kv
in
cbf_obj
.
cif
.
items
():
print
(
"
%s: %s
"
%
kv
)
raise
RuntimeError
(
err
)
if
cbf_obj
.
cif
[
fabio
.
cbfimage
.
CIF_BINARY_BLOCK_KEY
]
==
"
CIF Binary Section
"
:
cbf_obj
.
cbs
+=
infile
.
read
(
len
(
fabio
.
cbfimage
.
STARTER
)
+
int
(
cbf_obj
.
header
[
"
X-Binary-Size
"
])
if
cbf_obj
.
cif
[
cbf_obj
.
CIF_BINARY_BLOCK_KEY
]
==
"
CIF Binary Section
"
:
cbf_obj
.
cbs
+=
infile
.
read
(
len
(
cbf_obj
.
STARTER
)
+
int
(
cbf_obj
.
header
[
"
X-Binary-Size
"
])
-
len
(
cbf_obj
.
cbs
)
+
cbf_obj
.
start_binary
)
else
:
if
len
(
cbf_obj
.
cif
[
fabio
.
cbfimage
.
CIF_BINARY_BLOCK_KEY
])
>
int
(
cbf_obj
.
header
[
"
X-Binary-Size
"
])
+
cbf_obj
.
start_binary
+
len
(
fabio
.
cbfimage
.
STARTER
):
cbf_obj
.
cbs
=
cbf_obj
.
cif
[
fabio
.
cbfimage
.
CIF_BINARY_BLOCK_KEY
][:
int
(
cbf_obj
.
header
[
"
X-Binary-Size
"
])
+
cbf_obj
.
start_binary
+
len
(
fabio
.
cbfimage
.
STARTER
)]
if
len
(
cbf_obj
.
cif
[
cbf_obj
.
CIF_BINARY_BLOCK_KEY
])
>
int
(
cbf_obj
.
header
[
"
X-Binary-Size
"
])
+
cbf_obj
.
start_binary
+
len
(
cbf_obj
.
STARTER
):
cbf_obj
.
cbs
=
cbf_obj
.
cif
[
cbf_obj
.
CIF_BINARY_BLOCK_KEY
][:
int
(
cbf_obj
.
header
[
"
X-Binary-Size
"
])
+
cbf_obj
.
start_binary
+
len
(
cbf_obj
.
STARTER
)]
else
:
cbf_obj
.
cbs
=
cbf_obj
.
cif
[
fabio
.
cbfimage
.
CIF_BINARY_BLOCK_KEY
]
binary_data
=
cbf_obj
.
cbs
[
cbf_obj
.
start_binary
+
len
(
fabio
.
cbfimage
.
STARTER
):]
cbf_obj
.
cbs
=
cbf_obj
.
cif
[
cbf_obj
.
CIF_BINARY_BLOCK_KEY
]
binary_data
=
cbf_obj
.
cbs
[
cbf_obj
.
start_binary
+
len
(
cbf_obj
.
STARTER
):]
if
"
Content-MD5
"
in
cbf_obj
.
header
:
ref
=
numpy
.
string_
(
cbf_obj
.
header
[
"
Content-MD5
"
])
...
...
This diff is collapsed.
Click to expand it.
cfel_optarg.py
+
12
−
9
View file @
ca5834e1
...
...
@@ -12,14 +12,6 @@
#
# You should have received a copy of the GNU General Public License
# along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
"""
Utilities for parsing command line options and configuration files.
...
...
@@ -27,6 +19,10 @@ This module contains utilities for parsing of command line options and
configuration files.
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
ast
...
...
@@ -76,6 +72,11 @@ def parse_parameters(config):
monitor_params
[
sect
][
op
]
=
config
.
get
(
sect
,
op
)
if
monitor_params
[
sect
][
op
].
startswith
(
"'"
)
and
monitor_params
[
sect
][
op
].
endswith
(
"'"
):
monitor_params
[
sect
][
op
]
=
monitor_params
[
sect
][
op
][
1
:
-
1
]
try
:
monitor_params
[
sect
][
op
].
encode
(
'
ascii
'
)
except
UnicodeEncodeError
:
raise
RuntimeError
(
'
Error parsing parameters. Only ASCII characters are allowed in parameter
'
'
names and values.
'
)
continue
if
monitor_params
[
sect
][
op
].
startswith
(
'"'
)
and
monitor_params
[
sect
][
op
].
endswith
(
'"'
):
monitor_params
[
sect
][
op
]
=
monitor_params
[
sect
][
op
][
1
:
-
1
]
...
...
@@ -115,6 +116,8 @@ def parse_parameters(config):
monitor_params
[
sect
][
op
]
=
float
(
monitor_params
[
sect
][
op
])
continue
except
ValueError
:
pass
raise
RuntimeError
(
'
Error parsing parameters. The parameter {0}/{1} parameter has an invalid type.
'
'
Allowed types are None, int, float, bool and str. Strings must be
'
'
single-quoted.
'
.
format
(
sect
,
op
))
return
monitor_params
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