diff options
author | Maciej Kisielewski <maciej.kisielewski@canonical.com> | 2017-06-27 15:49:20 +0200 |
---|---|---|
committer | Maciej Kisielewski <maciej.kisielewski@canonical.com> | 2017-07-01 11:50:37 +0200 |
commit | b4f7222fe02caa3b93ee50bb0bf8f560c171ccf0 (patch) | |
tree | 07de1ed3777c8c935f2ea593abd399c101cdb30a /bin | |
parent | c6b63c5321c0b4652d0add678b9a0faf512855cb (diff) |
remove shutter.xml if already exists
Fixes: LP:1691724 There was a case of shutter.xml being owned by root - possibly due to running the job as root. This patch is kind of work around. It removes the previously created shutter.xml if it exists, making shutil.copy() not throw an exception. In a situation where the parent dir is also root's xrandr_cycle will report a warning and use existing shutter.xml Signed-off-by: Maciej Kisielewski <maciej.kisielewski@canonical.com>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/xrandr_cycle | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/bin/xrandr_cycle b/bin/xrandr_cycle index f7785624..2a5e9158 100755 --- a/bin/xrandr_cycle +++ b/bin/xrandr_cycle @@ -100,7 +100,14 @@ except OSError as excp: "required directories: {}".format(excp)) try: - shutil.copy(shutter_xml_template, profile_path) + if os.path.exists(profile_path) and os.path.isfile(profile_path): + try: + os.remove(profile_path) + except PermissionError as exc: + print("Warning: could not remove {}. {}".format( + profile_path, exc)) + else: + shutil.copy(shutter_xml_template, profile_path) except (IOError, OSError) as excp: print("ERROR: Unable to copy {} to {}: {}".format(shutter_xml_template, profile_path, |