"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/pymol/commanding.py" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

commanding.py  (pymol-v1.8.6.0.tar.bz2):commanding.py  (pymol-v2.1.0.tar.bz2)
skipping to change at line 22 skipping to change at line 22
#-* #-*
#Z* ------------------------------------------------------------------- #Z* -------------------------------------------------------------------
from __future__ import print_function, absolute_import from __future__ import print_function, absolute_import
if __name__=='pymol.commanding': if __name__=='pymol.commanding':
import sys import sys
if sys.version_info[0] == 2: if sys.version_info[0] == 2:
import thread import thread
import urllib2
else: else:
import _thread as thread import _thread as thread
import urllib.request as urllib2
from io import FileIO as file from io import FileIO as file
import re import re
import os import os
import time import time
import threading import threading
import traceback import traceback
from . import parsing from . import parsing
cmd = sys.modules["pymol.cmd"] cmd = sys.modules["pymol.cmd"]
import pymol import pymol
skipping to change at line 56 skipping to change at line 58
USAGE USAGE
resume filename resume filename
SEE ALSO SEE ALSO
log, log_close log, log_close
''' '''
pymol=_self._pymol
r = DEFAULT_ERROR r = DEFAULT_ERROR
if os.path.exists(filename): if os.path.exists(filename):
if(re.search(r"\.py$|\.PY$|\.pym$|.PYM$",filename)): if(re.search(r"\.py$|\.PY$|\.pym$|.PYM$",filename)):
r = _self.do("run %s"%filename) r = _self.do("run %s"%filename)
else: else:
r = _self.do("@%s"%filename) r = _self.do("@%s"%filename)
if is_ok(r): if is_ok(r):
r = _self.do("log_open %s,a"%filename) r = _self.do("log_open %s,a"%filename)
if _self._raising(r,_self): raise pymol.CmdException if _self._raising(r,_self): raise pymol.CmdException
return r return r
skipping to change at line 231 skipping to change at line 232
''' '''
r = DEFAULT_ERROR r = DEFAULT_ERROR
try: try:
_self.lock(_self) _self.lock(_self)
r = _cmd.cls(_self._COb) r = _cmd.cls(_self._COb)
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise pymol.CmdException if _self._raising(r,_self): raise pymol.CmdException
return r return r
def _load_splash_image(filename, url, _self=cmd):
import tempfile
import struct
tmp_filename = ""
contents = None
if url:
try:
handle = urllib2.urlopen(url)
contents = handle.read()
handle.close()
# png magic number
if contents[:4] != b'\x89\x50\x4e\x47':
raise IOError
shape = struct.unpack('>II', contents[16:24])
tmp_filename = tempfile.mktemp('.png')
with open(tmp_filename, 'wb') as handle:
handle.write(contents)
filename = tmp_filename
except IOError:
pass
if os.path.exists(filename) and not _self.get_names():
# hide text splash
print()
# fit window to image
try:
if not contents:
contents = open(filename, 'rb').read(24)
shape = struct.unpack('>II', contents[16:24])
scale = _self.get_setting_int('display_scale_factor')
_self.viewport(shape[0] * scale, shape[1] * scale)
except Exception as e:
print(e)
# load image
_self.load_png(filename, 0, quiet=1)
if tmp_filename:
os.unlink(tmp_filename)
def splash(mode=0, _self=cmd): def splash(mode=0, _self=cmd):
pymol=_self._pymol
cmd=_self cmd=_self
''' '''
DESCRIPTION DESCRIPTION
"splash" shows the splash screen information. "splash" shows the splash screen information.
USAGE USAGE
splash splash
''' '''
skipping to change at line 259 skipping to change at line 306
finally: finally:
_self.unlock(0,_self) _self.unlock(0,_self)
elif mode == 1: # just show PNG elif mode == 1: # just show PNG
show_splash = 1 show_splash = 1
try: try:
_self.lock(_self) _self.lock(_self)
show_splash = _cmd.splash(_self._COb,1) show_splash = _cmd.splash(_self._COb,1)
finally: finally:
_self.unlock(0,_self) _self.unlock(0,_self)
r = DEFAULT_SUCCESS r = DEFAULT_SUCCESS
png_url = ""
if show_splash==1: # generic / open-source if show_splash==1: # generic / open-source
png_path = _self.exp_path("$PYMOL_PATH/data/pymol/splash.png") png_path = _self.exp_path("$PYMOL_DATA/pymol/splash.png")
elif show_splash==2: # evaluation builds elif show_splash==2: # evaluation builds
png_path = _self.exp_path("$PYMOL_PATH/data/pymol/epymol.png") png_path = _self.exp_path("$PYMOL_DATA/pymol/epymol.png")
elif show_splash==3: # edu builds
png_path = _self.exp_path("$PYMOL_DATA/pymol/splash_edu.png")
png_url = "http://pymol.org/splash/splash_edu_2.png"
else: # incentive builds else: # incentive builds
png_path = _self.exp_path("$PYMOL_PATH/data/pymol/ipymol.png") png_path = _self.exp_path("$PYMOL_DATA/pymol/ipymol.png")
if os.path.exists(png_path):
_self.do("_ cmd.load_png('%s',0,quiet=1)"%png_path) t = threading.Thread(target=_load_splash_image, args=(png_path, png_
url, _self))
t.setDaemon(1)
t.start()
else: else:
if _self.get_setting_int("internal_feedback") > 0: if _self.get_setting_int("internal_feedback") > 0:
_self.set("text","1",quiet=1) _self.set("text","1",quiet=1)
print() print()
try: try:
_self.lock(_self) _self.lock(_self)
r = _cmd.splash(_self._COb,0) r = _cmd.splash(_self._COb,0)
finally: finally:
_self.unlock(r,_self) _self.unlock(r,_self)
if _self._raising(r,_self): raise pymol.CmdException if _self._raising(r,_self): raise pymol.CmdException
skipping to change at line 603 skipping to change at line 656
SEE ALSO SEE ALSO
cmd.extend, api cmd.extend, api
''' '''
_self.keyword[name] = [eval("lambda :do('''%s ''')"%command.replace("''' ","")), _self.keyword[name] = [eval("lambda :do('''%s ''')"%command.replace("''' ","")),
0,0,',',parsing.STRICT] 0,0,',',parsing.STRICT]
_self.kwhash.append(name) _self.kwhash.append(name)
async_threads = [] async_threads = []
def async(func, *args, **kwargs): def async_(func, *args, **kwargs):
''' '''
DESCRIPTION DESCRIPTION
Run function threaded and show "please wait..." message. Run function threaded and show "please wait..." message.
''' '''
from .wizard.message import Message from .wizard.message import Message
_self = kwargs.pop('_self', cmd) _self = kwargs.pop('_self', cmd)
wiz = Message(['please wait ...'], dismiss=0, _self=_self) wiz = Message(['please wait ...'], dismiss=0, _self=_self)
skipping to change at line 628 skipping to change at line 681
wiz = None wiz = None
if isinstance(func, str): if isinstance(func, str):
func = _self.keyword[func][0] func = _self.keyword[func][0]
def wrapper(): def wrapper():
async_threads.append(t) async_threads.append(t)
try: try:
func(*args, **kwargs) func(*args, **kwargs)
except (pymol.CmdException, cmd.QuietException) as e: except (pymol.CmdException, cmd.QuietException) as e:
if e.message: if e.args:
print(e) print(e)
finally: finally:
if wiz is not None: if wiz is not None:
try: try:
_self.set_wizard_stack([w _self.set_wizard_stack([w
for w in _self.get_wizard_stack() if w != wiz]) for w in _self.get_wizard_stack() if w != wiz])
except: except:
_self.do('_ wizard') _self.do('_ wizard')
else: else:
_self.refresh_wizard() _self.refresh_wizard()
 End of changes. 11 change blocks. 
9 lines changed or deleted 63 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)