#! /usr/bin/python3
# coding=utf-8

import sys
import IPython.core.interactiveshell

if len(sys.argv) == 1:
    print("No file given", file=sys.stderr)
    exit(1)

# A small hack to force IPython to interpret the given file as a IPYthon file.
# By default, it only parses correctly files with the .ipy extension.

shell = IPython.core.interactiveshell.InteractiveShell()
sys.argv = sys.argv[1:]  # correct the args

# Add the utility function to the global namespace
shell.run_cell("from inginious_container_api.input import *", store_history=False)
shell.run_cell("from inginious_container_api.feedback import *", store_history=False)
shell.run_cell("from inginious_container_api.lang import *", store_history=False)
shell.run_cell("from inginious_container_api.rst import *", store_history=False)
shell.run_cell("from inginious_container_api.run_student import *", store_history=False)
shell.run_cell("from inginious_container_api.ssh_student import *", store_history=False)
shell.run_cell("__file__ = \"" + sys.argv[0] + "\"", store_history=False)


shell.safe_execfile_ipy(sys.argv[0])