config: Allow specifying configfile location from command line
This commit is contained in:
parent
51da7cecc8
commit
bcbbc03151
@ -38,3 +38,6 @@ python virtual environment at ${HOME}/.KlipperScreen-env and install a systemd
|
||||
service file.
|
||||
|
||||
As an option to do development or interact with KlipperScreen from your computer, you may install tigervnc-scraping-server and VNC to your pi instance. Follow tigervnc server setup procedures for details on how to do that.
|
||||
|
||||
If you need a custom location for the configuration file, you can add -c or --configfile to the systemd file and specify
|
||||
the location of your configuration file.
|
||||
|
@ -1,5 +1,8 @@
|
||||
## Changelog
|
||||
|
||||
#### 2020 12 16
|
||||
* Config file can now be specified when running from the command line
|
||||
|
||||
#### 2020 12 09
|
||||
* Z value in job status now reflects the gcode Z value. This allows people with ABL to have a better understanding of Z
|
||||
|
||||
|
@ -16,10 +16,10 @@ class KlipperScreenConfig:
|
||||
config = None
|
||||
configfile_name = "KlipperScreen.conf"
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, configfile):
|
||||
self.default_config_path = "%s/ks_includes/%s" % (os.getcwd(), self.configfile_name)
|
||||
self.config = configparser.ConfigParser()
|
||||
self.config_path = self.get_config_file_location()
|
||||
self.config_path = self.get_config_file_location(configfile)
|
||||
|
||||
try:
|
||||
self.config.read(self.default_config_path)
|
||||
@ -32,8 +32,7 @@ class KlipperScreenConfig:
|
||||
self.get_menu_items("__main")
|
||||
#self.build_main_menu(self.config)
|
||||
|
||||
def get_config_file_location(self):
|
||||
file = "%s/%s" % (os.getenv("HOME"), self.configfile_name)
|
||||
def get_config_file_location(self, file):
|
||||
if not path.exists(file):
|
||||
file = "%s/%s" % (os.getcwd(), self.configfile_name)
|
||||
if not path.exists(file):
|
||||
|
13
screen.py
13
screen.py
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import argparse
|
||||
import gi
|
||||
import gettext
|
||||
import time
|
||||
@ -65,7 +66,17 @@ class KlipperScreen(Gtk.Window):
|
||||
def __init__(self):
|
||||
self.version = get_software_version()
|
||||
logger.info("KlipperScreen version: %s" % self.version)
|
||||
self._config = KlipperScreenConfig()
|
||||
|
||||
parser = argparse.ArgumentParser(description="KlipperScreen - A GUI for Klipper")
|
||||
parser.add_argument(
|
||||
"-c","--configfile", default="~/KlipperScreen.conf", metavar='<configfile>',
|
||||
help="Location of KlipperScreen configuration file"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
configfile = os.path.normpath(os.path.expanduser(args.configfile))
|
||||
|
||||
|
||||
self._config = KlipperScreenConfig(configfile)
|
||||
self.printer = Printer({
|
||||
"software_version": "Unknown"
|
||||
}, {
|
||||
|
Loading…
x
Reference in New Issue
Block a user