aboutsummaryrefslogtreecommitdiff
path: root/scripts/boot.py
blob: 3e715aa10363ab6315391984db803ac5d10d8682 (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
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():
	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()), "a") 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)