<commit_before>#!/usr/bin/env python
import sys
from octoprint.daemon import Daemon
from octoprint.server import Server

class Main(Daemon):
	def __init__(self, pidfile, configfile, basedir, host, port, debug):
		Daemon.__init__(self, pidfile)

		self._configfile = configfile
		self._basedir = basedir
		self._host = host
		self._port = port
		self._debug = debug

	def run(self):
		octoprint = Server(self._configfile, self._basedir, self._host, self._port, self._debug)
		octoprint.run()

def main():
	import argparse

	parser = argparse.ArgumentParser(prog="run")

	parser.add_argument("-d", "--debug", action="store_true", dest="debug",
						help="Enable debug mode")

	parser.add_argument("--host", action="store", type=str, dest="host",
						help="Specify the host on which to bind the server")
	parser.add_argument("--port", action="store", type=int, dest="port",
						help="Specify the port on which to bind the server")

	parser.add_argument("-c", "--config", action="store", dest="config",
						help="Specify the config file to use. OctoPrint needs to have write access for the settings dialog to work. Defaults to ~/.octoprint/config.yaml")
	parser.add_argument("-b", "--basedir", action="store", dest="basedir",
						help="Specify the basedir to use for uploads, timelapses etc. OctoPrint needs to have write access. Defaults to ~/.octoprint")

	parser.add_argument("--daemon", action="store", type=str, choices=["start", "stop", "restart"],
						help="Daemonize/control daemonized OctoPrint instance (only supported under Linux right now)")
	parser.add_argument("--pid", action="store", type=str, dest="pidfile", default="/tmp/octoprint.pid",
						help="Pidfile to use for daemonizing, defaults to /tmp/octoprint.pid")

	parser.add_argument("--iknowwhatimdoing", action="store_true", dest="allowRoot",
						help="Allow OctoPrint to run as user root")

	args = parser.parse_args()

	if args.daemon:
		if sys.platform == "darwin" or sys.platform == "win32":
			print >> sys.stderr, "Sorry, daemon mode is only supported under Linux right now"
			sys.exit(2)

		daemon = Main(args.pidfile, args.config, args.basedir, args.host, args.port, args.debug)
		if "start" == args.daemon:
			daemon.start()
		elif "stop" == args.daemon:
			daemon.stop()
		elif "restart" == args.daemon:
			daemon.restart()
	else:
		octoprint = Server(args.config, args.basedir, args.host, args.port, args.debug, args.allowRoot)<commit_msg>Also recognize --iknowwhatimdoing when running as daemon<commit_after>#!/usr/bin/env python
import sys
from octoprint.daemon import Daemon
from octoprint.server import Server


class Main(Daemon):
	def __init__(self, pidfile, configfile, basedir, host, port, debug, allowRoot):
		Daemon.__init__(self, pidfile)

		self._configfile = configfile
		self._basedir = basedir
		self._host = host
		self._port = port
		self._debug = debug
		self._allowRoot = allowRoot

	def run(self):
		octoprint = Server(self._configfile, self._basedir, self._host, self._port, self._debug, self._allowRoot)
		octoprint.run()

def main():
	import argparse

	parser = argparse.ArgumentParser(prog="run")

	parser.add_argument("-d", "--debug", action="store_true", dest="debug",
						help="Enable debug mode")

	parser.add_argument("--host", action="store", type=str, dest="host",
						help="Specify the host on which to bind the server")
	parser.add_argument("--port", action="store", type=int, dest="port",
						help="Specify the port on which to bind the server")

	parser.add_argument("-c", "--config", action="store", dest="config",
						help="Specify the config file to use. OctoPrint needs to have write access for the settings dialog to work. Defaults to ~/.octoprint/config.yaml")
	parser.add_argument("-b", "--basedir", action="store", dest="basedir",
						help="Specify the basedir to use for uploads, timelapses etc. OctoPrint needs to have write access. Defaults to ~/.octoprint")

	parser.add_argument("--daemon", action="store", type=str, choices=["start", "stop", "restart"],
						help="Daemonize/control daemonized OctoPrint instance (only supported under Linux right now)")
	parser.add_argument("--pid", action="store", type=str, dest="pidfile", default="/tmp/octoprint.pid",
						help="Pidfile to use for daemonizing, defaults to /tmp/octoprint.pid")

	parser.add_argument("--iknowwhatimdoing", action="store_true", dest="allowRoot",
						help="Allow OctoPrint to run as user root")

	args = parser.parse_args()

	if args.daemon:
		if sys.platform == "darwin" or sys.platform == "win32":
			print >> sys.stderr, "Sorry, daemon mode is only supported under Linux right now"
			sys.exit(2)

		daemon = Main(args.pidfile, args.config, args.basedir, args.host, args.port, args.debug, args.allowRoot)
		if "start" == args.daemon:
			daemon.start()
		elif "stop" == args.daemon:
			daemon.stop()
		elif "restart" == args.daemon:
			daemon.restart()
	else:
		octoprint = Server(args.config, args.basedir, args.host, args.port, args.debug, args.allowRoot)
{'fraction_non_alphanumeric': 0.14386035313001605, 'fraction_numerical': 0.001203852327447833, 'mean_word_length': 4.557413600891862, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1520854', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1603, 'n_words': 446}