From: Eliseo Ocampos Date: Thu, 10 Mar 2016 16:24:31 +0000 (-0300) Subject: Set configuration file ownership X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=commitdiff_plain;h=fe9ce36c94cd4207aaf5e99aa7e1fd183b944b78;ds=sidebyside Set configuration file ownership Set the proper file ownership if installed with sudo. This avoids constants error messages when trying to change/delete configuration values (chmod: changing permissions of ...: Operation not permitted) Signed-off-by: Eliseo Ocampos --- diff --git a/setup.py b/setup.py index 10f5094..fe06534 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,12 @@ from setuptools import setup, find_packages import os import os.path +import sys + +if sys.version[0] == "2": + from pipes import quote +else: + from shlex import quote # Bumped version version = '1.3.3' @@ -16,11 +22,16 @@ install_requires = [ "PySocks" ] +# Default user (considers non virtualenv method) +user = os.environ.get('SUDO_USER', os.environ['USER']) + # Copy default config if not exists default = os.path.expanduser("~") + os.sep + '.rainbow_config.json' if not os.path.isfile(default): cmd = 'cp rainbowstream/colorset/config ' + default os.system(cmd) + cmd = 'chown ' + quote(user) + ' ' + default + os.system(cmd) cmd = 'chmod 777 ' + default os.system(cmd)