Skip to content

Commit

Permalink
Merge pull request #104 from ska-sa/issue-101
Browse files Browse the repository at this point in the history
Fixes #101 and #103
  • Loading branch information
o-smirnov authored Jul 15, 2020
2 parents 13247b8 + d268f99 commit 8c036db
Show file tree
Hide file tree
Showing 28 changed files with 17 additions and 14 deletions.
1 change: 0 additions & 1 deletion Pyxides/im/argo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

# register ourselves with Pyxis and define the superglobals
register_pyxis_module(superglobals="MS LSM")
register_pyxis_module()

rm_fr = x.rm.args("-fr")

Expand Down
2 changes: 0 additions & 2 deletions Pyxides/imager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from Pyxides.im import argo

from Pyxis.ModSupport import *

register_pyxis_module(superglobals="MS LSM DESTDIR");
Expand Down
11 changes: 6 additions & 5 deletions Pyxis/Internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import fnmatch
import shutil
import shlex
import six

import Pyxis

Expand Down Expand Up @@ -725,15 +726,15 @@ def set_logfile (filename,quiet=False):
sys.stdout,sys.stderr = sys.__stdout__,sys.__stderr__;
_current_logobj = None;
else:
mode = "wa";
mode = "a";
# append to file if name starts with +, or if file has already been used as a log this session, or if flush is off
if Pyxis.Context.get("LOG_FLUSH"):
mode = "w";
if filename[0] == '+':
filename = filename[1:];
mode = "wa";
mode = "a";
if filename in _visited_logfiles:
mode = "wa";
mode = "a";
Pyxis.ModSupport.makedir(os.path.dirname(filename),no_interpolate=True);
_current_logobj = sys.stdout = sys.stderr = open(filename,mode);
hdr = Pyxis.Context.get("LOG_HEADER");
Expand Down Expand Up @@ -786,7 +787,7 @@ def initconf (force=False,files=[],directory="."):
if Pyxis.Context.get("PYXIS_AUTO_IMPORT_MODULES",True) and toplevel:
_verbose(1,"importing top-level modules (%s) for you. Preset PYXIS_AUTO_IMPORT_MODULES=False to disable."%", ".join(toplevel));
for mod in toplevel:
Pyxis.Context[mod] = sys.modules.get(mod,sys.modules.get("Pyxides."+m));
Pyxis.Context[mod] = sys.modules.get(mod, sys.modules.get("Pyxides."+mod));

def loadconf (filename,frame=None,chdir=True):
"""Loads config file""";
Expand Down Expand Up @@ -822,7 +823,7 @@ def load_package (pkgname,filename,chdir=True,report=True):
if dirname not in oldpath:
sys.path.append(dirname);
try:
exec(open(filename),Pyxis.Context);
exec(open(filename, "rt").read(), Pyxis.Context, Pyxis.Context)
finally:
sys.path = oldpath;
except SystemExit:
Expand Down
7 changes: 4 additions & 3 deletions Pyxis/ModSupport.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Pyxis.ModSupport: functions for programming Pyxides modules"""

import fnmatch
import fnmatch
import inspect, traceback

import Pyxis
from Pyxis import *
Expand All @@ -20,10 +21,10 @@ def register_pyxis_module (superglobals=""):
module = sys.modules[modname];
if modname.startswith("Pyxides."):
modname = modname.split(".",1)[-1];
# check for double registration
if id(globs) in _superglobals:
if _modules[modname] is not module:
raise RuntimeError("a different Pyxis module named '%s' is already registered"%modname);
return
_modules[modname] = module;
# build list of superglobals
if isinstance(superglobals,str):
Expand All @@ -34,7 +35,7 @@ def register_pyxis_module (superglobals=""):
_verbose(1,"registered module '%s'"%modname);
_namespaces[modname] = globs;
_superglobals[id(globs)] = superglobs;
Pyxis.Context[modname] = __import__(modname,Pyxis.Context);
Pyxis.Context[modname] = module;
# add superglobals
for sym in superglobs:
# if superglobal is already defined, copy its value to the new module
Expand Down
4 changes: 3 additions & 1 deletion Pyxis/doc/example/pyxis-wsrt21cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# import some Pyxides modules.
# Note that Pyxides is implicitly added to the include path
# when you import Pyxis above
import ms,imager,std,lsm,stefcal
import ms,imager,std,lsm

from Cattery.Pyxides import stefcal

# import some other Python modules that we make use of below
from astropy.io import fits as pyfits
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
PYXIS_ROOT_NAMESPACE = True # must set this before import!
import Pyxis
import Pyxides
PACKAGE_TEST_DIR = os.path.join(os.path.dirname(Pyxis.__file__), "recipies", "imagers-test")
PACKAGE_TEST_DIR = os.path.join(os.path.dirname(Pyxis.__file__), "recipes", "imagers-test")
if not os.path.exists(PACKAGE_TEST_DIR):
raise RuntimeError("Installation excludes {}".format(PACKAGE_TEST_DIR))
except:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
PYXIS_ROOT_NAMESPACE = True # must set this before import!
import Pyxis
import Pyxides
PACKAGE_TEST_DIR = os.path.join(os.path.dirname(Pyxis.__file__), "recipies", "meqtrees-batch-test")
PACKAGE_TEST_DIR = os.path.join(os.path.dirname(Pyxis.__file__), "recipes", "meqtrees-batch-test")
if not os.path.exists(PACKAGE_TEST_DIR):
raise RuntimeError("Installation excludes {}".format(PACKAGE_TEST_DIR))
except:
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
'matplotlib',
'python_casacore',
'numpy<=1.16',
'scipy',
'future'
] if six.PY2 else [
'astropy>=3.0',
# 'timba', not available on pypi
'matplotlib',
'python_casacore',
'numpy>=1.16',
'scipy',
'future'
]

Expand Down

0 comments on commit 8c036db

Please sign in to comment.