Attention: Maintenance on monday 19.04.2021 from 07:00 - 13:00 (Gitlab and Mattermost are offline!)

Commit 5645356f authored by Theresa Pollinger's avatar Theresa Pollinger

putting and executing exastencils in users home

parent 51ed0bc8
......@@ -19,7 +19,7 @@ class ExaOutput:
but only if simdata is given"""
def __init__(self, simdata=None, username="user", probname=None):
remove_ensuremaths()
self.exastencils_path = Path(os.path.dirname(__file__)).joinpath("./exastencils")
self.exastencils_path = Path.home().joinpath("./exastencils")
self.username = username
......@@ -179,7 +179,7 @@ class ExaOutput:
def create_l4(self):
l4path = str(self.filespath.with_suffix('.exa4'))
with open(l4path,'w') as l4:
with open(l4path, 'w') as l4:
l4.write(
"Function Application ( ) : Unit { \n"
" startTimer ( 'setup' ) \n"
......@@ -227,13 +227,13 @@ class ExaOutput:
def create_platform(self):
platformpath = str(self.filespath) + '.platform'
with open(platformpath,'w') as platformfile:
with open(platformpath, 'w') as platformfile:
for key in self.platform:
platformfile.write(self.format_key(key, self.platform))
def create_knowledge(self):
knowledgepath = str(self.filespath) + '.knowledge'
with open(knowledgepath,'w') as knowledgefile:
with open(knowledgepath, 'w') as knowledgefile:
# for key in self.knowledge:
# knowledgefile.write(self.format_key(key, self.knowledge))
knowledgefile.write(
......@@ -271,7 +271,8 @@ class ExaRunner:
@lru_cache()
def load_data(self, data_name="u"): # TODO more dimensions
import pandas as pd
data_path = self.exaout.exastencils_path.joinpath("generated").joinpath(self.exaout.probname).joinpath(data_name).with_suffix(".dat")
data_path = self.exaout.exastencils_path.joinpath("generated").joinpath(self.exaout.probname)\
.joinpath(data_name).with_suffix(".dat")
df = pd.read_csv(data_path, sep=' ', index_col=0)
try:
df.columns = [data_name]
......
......@@ -7,8 +7,9 @@ from .interview_kernel import Interview
from jupyter_client.kernelspec import KernelSpecManager
from IPython.utils.tempdir import TemporaryDirectory
from shutil import copyfile
import shutil
import errno
from pathlib import Path
kernel_json = {
......@@ -22,7 +23,7 @@ kernel_json = {
def install_my_kernel_spec(user=True, prefix=None):
with TemporaryDirectory() as td:
os.chmod(td, 0o755) # Starts off as 700, not user readable
os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
try:
......@@ -50,11 +51,23 @@ def install_my_kernel_spec(user=True, prefix=None):
except Exception:
print('could not copy kernel.js, will not see initial message in notebook')
#raise
print("Installing Jupyter kernel spec")
KernelSpecManager().install_kernel_spec(td, 'Interview', user=user, prefix=prefix)
# copy exastencils directory to user's home
src = Path(os.path.dirname(__file__)).joinpath("./exastencils")
dest = Path.home().joinpath("./exastencils")
try:
shutil.copytree(src, dest)
except OSError as e:
# If the error was caused because the source wasn't a directory
if e.errno == errno.ENOTDIR:
shutil.copy(src, dest)
else:
print('Directory not copied. Error: %s' % e)
def _is_root():
try:
return os.geteuid() == 0
......
......@@ -90,7 +90,7 @@ Otherwise, you can always answer with \LaTeX-type input.
def do_execute_direct(self, code, silent=False, allow_stdin=True):
"""This is where the user input enters our code"""
arg = string_handling.replace_times_to_cdot(LatexNodes2Text().latex_to_text(code))
arg = string_handling.replace_times_to_cdot(LatexNodes2Text().latex_to_text(code)).strip()
if not self.keyword_handling(arg):
if not self.prompt_input_handling(arg):
......@@ -101,12 +101,6 @@ Otherwise, you can always answer with \LaTeX-type input.
# string output
stream_content = {'name': self.outstream_name, 'text': self.poutstring}
self.send_response(self.iopub_socket, 'stream', stream_content)
# data_content = {
# "ename": "InterviewError",
# "evalue": self.poutstring,
# "traceback": [self.poutstring],
# }
# self.send_response(self.iopub_socket, 'error', data_content)
else:
# for other mime types, cf. http://ipython.org/ipython-doc/stable/notebook/nbformat.html
data_content = {"data": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment