Changed cofig editor to system default (#41), used more readable code for user detection (#46)

This commit is contained in:
boltgolt 2018-06-28 14:18:27 +02:00
parent 440cec8944
commit 38eff8149d
No known key found for this signature in database
GPG key ID: BECEC9937E1AAE26
4 changed files with 11 additions and 11 deletions

2
debian/postinst vendored
View file

@ -223,7 +223,7 @@ if "HOWDY_NO_PROMPT" not in os.environ:
diag_out += "```"
# Print it all as a clickable link to a new github issue
print("https://github.com/Boltgolt/howdy-reports/issues/new?title=Post-installation%20camera%20information&body=" + urllib.parse.quote_plus(diag_out) + "\n")
print("https://github.com/boltgolt/howdy-reports/issues/new?title=Post-installation%20camera%20information&body=" + urllib.parse.quote_plus(diag_out) + "\n")
# Let the user know what to do with the link
print("Installation complete.")

View file

@ -10,10 +10,13 @@ import argparse
import builtins
# Try to get the original username (not "root") from shell
user = subprocess.check_output("echo $(logname 2>/dev/null || echo $SUDO_USER)", shell=True).decode("ascii").strip()
try:
user = os.getlogin()
except:
user = os.environ.get("SUDO_USER")
# If that fails, try to get the direct user
if user == "root" or user == "":
if user == "root" or user == None:
env_user = getpass.getuser().strip()
# If even that fails, error out
@ -73,7 +76,8 @@ builtins.howdy_user = args.user
# Check if we have rootish rights
# This is this far down the file so running the command for help is always possible
if os.getenv("SUDO_USER") is None:
print("Please run this command with sudo")
print("Please run this command as root:\n")
print("\tsudo howdy " + " ".join(sys.argv[1:]))
sys.exit(1)
# Beond this point the user can't change anymore, if we still have root as user we need to abort

View file

@ -6,10 +6,7 @@ import time
import subprocess
# Let the user know what we're doing
print("Opening config.ini in gedit")
print("Opening config.ini in the default editor")
# Open gedit as a subprocess and fork it
subprocess.Popen(["gedit", os.path.dirname(os.path.realpath(__file__)) + "/../config.ini"],
cwd="/",
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
subprocess.call(["/etc/alternatives/editor", os.path.dirname(os.path.realpath(__file__)) + "/../config.ini"])

View file

@ -1,4 +1,5 @@
# Howdy config file
# Press CTRL + X to save in the nano editor
[core]
# Do not print anything when a face verification succeeds
@ -46,5 +47,3 @@ dark_threshold = 50
[debug]
# Show a short but detailed diagnostic report in console
end_report = false
dummy = true