aboutsummaryrefslogtreecommitdiff
path: root/scripts/boot.py
blob: d03504a64e1d5a4d6bbfbe52a39a37f7285ad35c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import sys
import subprocess
import shutil
import importlib

import utils
import initialize
from conf import conf
from conf import sf
from exceptions import MissingFile

def boot():
	if not os.path.isfile((conf.nbscript)):
		initialize.gen_nbscript()
	try:
		os.mkdir(sf(conf.output_folder))
	except FileExistsError:
			pass

	wd = os.getcwd()

	sprc = subprocess.Popen(conf.boot_command,
			stdout = subprocess.PIPE)
	with open(os.path.join(sf(conf.output_folder), utils.get_last_configuration()), "w") as f:
		for linen in sprc.stdout:
			line = linen.decode('utf-8')
			if conf.boot_output:
				print(line, end="")
			f.write(line)

	os.chdir(wd)