summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2014-07-25 12:41:25 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2014-07-25 12:43:34 -0300
commitc4df5cff32524bf2fa9e5d43f08210361531d273 (patch)
tree4753e06a3180ffb6197527d074c9a3d6c3ab3def
parented93cbe97f7898d0759e63f9917f7d001a2e9b78 (diff)
Create the autostart path in case that does not exist.
-rw-r--r--src/leap/bitmask/util/autostart.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/leap/bitmask/util/autostart.py b/src/leap/bitmask/util/autostart.py
index 5f003bd8..d7a8afb8 100644
--- a/src/leap/bitmask/util/autostart.py
+++ b/src/leap/bitmask/util/autostart.py
@@ -22,6 +22,7 @@ import os
from leap.bitmask.config import flags
from leap.bitmask.platform_init import IS_LINUX
+from leap.common.files import mkdir_p
logger = logging.getLogger(__name__)
@@ -38,7 +39,8 @@ Terminal=false
Icon=bitmask
"""
-DESKTOP_ENTRY_PATH = os.path.expanduser("~/.config/autostart/bitmask.desktop")
+DESKTOP_ENTRY_PATH = os.path.expanduser("~/.config/autostart/")
+DESKTOP_ENTRY_FILE = os.path.join(DESKTOP_ENTRY_PATH, 'bitmask.desktop')
def set_autostart(enabled):
@@ -56,11 +58,12 @@ def set_autostart(enabled):
return
if enabled:
- with open(DESKTOP_ENTRY_PATH, 'w') as f:
+ mkdir_p(DESKTOP_ENTRY_PATH)
+ with open(DESKTOP_ENTRY_FILE, 'w') as f:
f.write(DESKTOP_ENTRY)
else:
try:
- os.remove(DESKTOP_ENTRY_PATH)
+ os.remove(DESKTOP_ENTRY_FILE)
except OSError: # if the file does not exist
pass
except Exception as e: