Skip to content
Snippets Groups Projects
Commit 1a173984 authored by Olivier Bertrand's avatar Olivier Bertrand
Browse files

Merge branch 'master' into twomarkerorient

parents 78165702 1a83514b
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,18 @@ python setup.py install
```
## Blender-python version
Navipy can be interfaced with blender. It is highly recommended to use the same version of packages of blender when doing so, in order to reduce problem of compatibility.
To determine the packages that you will need, you can run the script: `navipy/script/check_blender_versions_pip.py` in blender or via commandline:
```
blender -b -P check_blender_versions_pip.py
```
It will create a textfile containing all packages used by blender. They can be installed in your virtualenvironment (prior to navipy) by doing:
```
pip install -r requirement.txt
```
| Blender version | Python version |
| --------------- | -------------- |
| 2.79b | 3.5.3 |
......
......@@ -704,6 +704,20 @@ class DataBase():
WHERE (rowid=?)
""".format(tablename), (rowid,))
image = self.db_cursor.fetchone()[0]
# Check image size
# and try to correct it whenever possible
if not isinstance(image, np.ndarray):
msg = 'image must be np.array'
self._logger.exception(msg)
raise TypeError(msg)
if len(image.shape) > 3:
if np.all(image.shape[3:] == np.ones_like(image.shape[3:])):
image = image[:, :, :, 0] # Other dim are useless
if len(image.shape) != 3:
msg = 'image should be 3D array'
msg += 'image size is {}'.format(image.shape)
self._logger.exception(msg)
raise Exception(msg)
# Read cmaxminrange
tablename = 'normalisation'
cmaxminrange = pd.read_sql_query(
......
......@@ -56,7 +56,12 @@ def parser_blend_alongtraj():
type=str,
default=None,
help=arghelp)
arghelp = 'To ignore the autocheck of python version'
arghelp += 'and blender'
parser.add_argument('--ignorepycheck',
default=0,
help=arghelp,
action='count')
return parser
......@@ -100,14 +105,19 @@ def main():
tfile.write('except Exception:\n'.encode(encoding))
tfile.write(' sys.exit(1)\n'.encode(encoding))
tfile.seek(0)
if args.ignorepycheck == 0:
ignorepyversion = ''
else:
ignorepyversion = '--ignorepycheck '
command = 'blendnavipy --background '
command = 'blendnavipy --background {}'.format(ignorepyversion)
command += '--blender-world {} --python-script {}'
command = command.format(args.blender_world, tfile.name)
if args.blender_command is not None:
command += ' --blender-command {}'.format(args.blender_command)
for _ in range(args.verbose):
command += ' -v'
print(command)
os.system(command)
......
......@@ -82,6 +82,13 @@ def parser_blendnavipy():
action='count',
default=0,
help=arghelp)
arghelp = 'To ignore the autocheck of python version'
arghelp += 'and blender'
parser.add_argument('--ignorepycheck',
default=0,
help=arghelp,
action='count')
return parser
......@@ -120,14 +127,17 @@ def main():
with tempfile.NamedTemporaryFile() as tfile:
# Start of file
tfile.write(header.encode(encoding))
# Check blender version
tfile.write('# check blender version\n'.encode(encoding))
tfile.write('import sys \n'.encode(encoding))
tfile.write('import os \n'.encode(encoding))
for line in inspect.getsourcelines(blender_version)[0]:
if args.ignorepycheck == 0:
for line in inspect.getsourcelines(blender_version)[0]:
tfile.write(line.encode(encoding))
tfile.write('\n\n'.encode(encoding))
line = 'blender_version({})\n'.format(pyver)
tfile.write(line.encode(encoding))
tfile.write('\n\n'.encode(encoding))
line = 'blender_version({})\n'.format(pyver)
tfile.write(line.encode(encoding))
# Load venv
if venv_path is not None:
tfile.write(
'# activate virtualenv within blender\n'.encode(encoding))
......
"""
List all installed packages in a python installation
by using pip.
It can be used to install a virtual environment, so that it matches
another installation (for example blender)
"""
import pip
installed_packages = pip.get_installed_distributions()
installed_packages = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
with open('requirement.txt', 'w') as cfile:
for line in installed_packages:
print(line)
cfile.write(line+'\n')
......@@ -792,6 +792,7 @@ series.
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
elif len(plotcoords) == 2:
fig = plt.figure()
ax = fig.add_subplot(111)
if (len(plotcoords) != 2) and (len(plotcoords) != 3):
msg = 'plotcoords need to contains 2 or 3 elements'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment