mirror of
https://gitlab.rlp.net/pgp/pgp1-python-einfuehrung
synced 2024-11-16 13:48:11 +00:00
Set-up file which will set-up the custom settings.
This commit is contained in:
parent
f81b29e039
commit
4d0db3c4fe
1 changed files with 115 additions and 0 deletions
115
Custom_Set_up.ipynb
Normal file
115
Custom_Set_up.ipynb
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2019-09-20T20:32:38.385152Z",
|
||||||
|
"start_time": "2019-09-20T20:32:29.330519Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Checking first your IPython version...\n",
|
||||||
|
"Setting up a custom made Jupyter Style.\n",
|
||||||
|
"Searching for the Jupyter profile directory...\n",
|
||||||
|
"Your Jupyter profile directory is allocated at C:\\Users\\Daniel\\.jupyter\n",
|
||||||
|
"Checking if either the custom directory or a custom.css file already exists.\n",
|
||||||
|
"The custom directory exists, but no custom.css file was found.\n",
|
||||||
|
"Copying data now.\n",
|
||||||
|
"Done! Your custom.css file is now allocated at C:\\Users\\Daniel\\.jupyter\\custom\\custom.css\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# Small program to put a custom.css file from the course material \n",
|
||||||
|
"# directory to the correct location on the students machines.\n",
|
||||||
|
"# \n",
|
||||||
|
"# Since the directory sturcture for the custom.css file changed \n",
|
||||||
|
"# this set-up only works for IPython and Jupyter versions after \n",
|
||||||
|
"# the so called the \"big splitt\" (version 4 and higher).\n",
|
||||||
|
"import os\n",
|
||||||
|
"import sys\n",
|
||||||
|
"import jupyter_core\n",
|
||||||
|
"import IPython\n",
|
||||||
|
"import shutil\n",
|
||||||
|
"from time import sleep \n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"print('Checking first your IPython version...')\n",
|
||||||
|
"sleep(2)\n",
|
||||||
|
"version1,version2,__,__ = IPython.version_info # Checking for the IPython version \n",
|
||||||
|
" # Returns the version number as tuble with integer\n",
|
||||||
|
"\n",
|
||||||
|
"if (version1 + version2/10) < 4:\n",
|
||||||
|
" print('''Your IPython version is only %i.%i. \n",
|
||||||
|
"This set-up program requires an IPython version after the \"big splitt\" (4.0 or higher).\n",
|
||||||
|
"Please contact the tutor.'''% (version1,version2)) \n",
|
||||||
|
"\n",
|
||||||
|
"else:\n",
|
||||||
|
" script_dir = os.path.abspath('') # Gets the directory name of the current set-up file\n",
|
||||||
|
" custiom_source_file = os.path.join(script_dir,'custom.css')\n",
|
||||||
|
" print('''Setting up a custom made Jupyter Style.\n",
|
||||||
|
"Searching for the Jupyter profile directory...''')\n",
|
||||||
|
" sleep(2)\n",
|
||||||
|
" jupyter_path = jupyter_core.paths.jupyter_config_dir()\n",
|
||||||
|
" print(r'Your Jupyter profile directory is allocated at %s'% jupyter_path)\n",
|
||||||
|
" sleep(2)\n",
|
||||||
|
" print('Checking if either the custom directory or a custom.css file already exists.')\n",
|
||||||
|
" sleep(2)\n",
|
||||||
|
" custom_dir = os.path.join(jupyter_path,'custom')\n",
|
||||||
|
" custom_file = os.path.join(custom_dir,'custom.css')\n",
|
||||||
|
"\n",
|
||||||
|
" if os.path.isdir(custom_dir) and os.path.exists(custom_file):\n",
|
||||||
|
" print('''The custom.css file already exists. \n",
|
||||||
|
"How do you want to proceed?''')\n",
|
||||||
|
" sleep(2)\n",
|
||||||
|
"\n",
|
||||||
|
" proceed = input('''Would you either like to delte the already existing custom.css file (d), \n",
|
||||||
|
"or stop the custom.css set up? (s)''')\n",
|
||||||
|
" if proceed == 's':\n",
|
||||||
|
" print('The installation will be stoped.')\n",
|
||||||
|
" elif proceed == 'd':\n",
|
||||||
|
" os.remove(custom_file)\n",
|
||||||
|
" else:\n",
|
||||||
|
" print('Wrong keyboard input the installation will be stoped.')\n",
|
||||||
|
"\n",
|
||||||
|
" elif os.path.isdir(custom_dir):\n",
|
||||||
|
" print('''The custom directory exists, but no custom.css file was found.\n",
|
||||||
|
"Copying data now.''')\n",
|
||||||
|
" shutil.copy(custiom_source_file, custom_dir)\n",
|
||||||
|
" sleep(1)\n",
|
||||||
|
" print(r'Done! Your custom.css file is now allocated at %s'% custom_file)\n",
|
||||||
|
" else:\n",
|
||||||
|
" print('The custom directory does not exists creating a new one.')\n",
|
||||||
|
" os.makedirs(custom_dir, exist_ok = True)\n",
|
||||||
|
" sleep(2)\n",
|
||||||
|
" print('Directory has been created, copying data now.')\n",
|
||||||
|
" shutil.copy(custiom_source_file, custom_dir)\n",
|
||||||
|
" sleep(1)\n",
|
||||||
|
" print(r'Done! Your custom.css file is now allocated at %s'% custom_file)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"anaconda-cloud": {},
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 1
|
||||||
|
}
|
Loading…
Reference in a new issue