Calum Lind : Fix #1504 - Win32 run deluged as not logged in user via runas or service

0 views
Skip to first unread message

g...@deluge-torrent.org

unread,
Dec 17, 2012, 9:13:32 PM12/17/12
to deluge...@googlegroups.com
Module: deluge
Branch: master
Commit: f47c9186bf3a8e21d20d797e3a56b45d92f0a10e

Author: Calum Lind <calumlin...@gmail.com>
Date: Mon May 30 12:48:23 2011 +0100

Fix #1504 - Win32 run deluged as not logged in user via runas or service

---

deluge/common.py | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/deluge/common.py b/deluge/common.py
index b9a19ee..eaaa3b1 100644
--- a/deluge/common.py
+++ b/deluge/common.py
@@ -136,10 +136,17 @@ def get_default_config_dir(filename=None):

"""
if windows_check():
+ appDataPath = os.environ.get("APPDATA")
+ if not appDataPath:
+ import _winreg
+ hkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders")
+ appDataReg = _winreg.QueryValueEx(hkey, "AppData")
+ appDataPath = appDataReg[0]
+ _winreg.CloseKey(hkey)
if filename:
- return os.path.join(os.environ.get("APPDATA"), "deluge", filename)
+ return os.path.join(appDataPath, "deluge", filename)
else:
- return os.path.join(os.environ.get("APPDATA"), "deluge")
+ return os.path.join(appDataPath, "deluge")
else:
import xdg.BaseDirectory
if filename:

Reply all
Reply to author
Forward
0 new messages