summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-03-19 16:07:21 +0100
committerhut <hut@lavabit.com>2010-03-19 16:07:21 +0100
commit3547d30049f40abcc6daa5626643446e5c9963cb (patch)
tree963306d698f3d41fa97baf9a7f9c92916738f18c
parentf45f3c7349fbbc2ec464b5587da564e4e82423f0 (diff)
downloadranger-3547d30049f40abcc6daa5626643446e5c9963cb.tar.gz
core.environment: new attributes: username, hostname, hone_path
-rw-r--r--ranger/core/environment.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index 984db57c..a30b8dcd 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -13,12 +13,15 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from os.path import abspath, normpath, join, expanduser, isdir
+import curses
 import os
+import pwd
+import socket
+from os.path import abspath, normpath, join, expanduser, isdir
+
 from ranger.fsobject.directory import Directory, NoDirectoryGiven
 from ranger.container import KeyBuffer, History
 from ranger.shared import SettingsAware
-import curses
 
 class Environment(SettingsAware):
 	"""A collection of data which is relevant for more than
@@ -46,6 +49,13 @@ class Environment(SettingsAware):
 		self.copy = set()
 		self.history = History(self.settings.max_history_size)
 
+		try:
+			self.username = pwd.getpwuid(os.geteuid()).pw_name
+		except:
+			self.username = 'uid:' + str(os.geteuid())
+		self.hostname = socket.gethostname()
+		self.home_path = os.path.expanduser('~')
+
 		from ranger.shared import EnvironmentAware
 		EnvironmentAware.env = self