5
_boldcode = os.popen('tput bold', 'r').read()
6
_normal = os.popen('tput rmso', 'r').read()
8
import pygtk; pygtk.require("2.0")
12
def __init__(self, cwd=None):
14
self.cwd = gnomevfs.URI(cwd)
16
self.cwd = gnomevfs.URI(os.getcwd())
17
if str(self.cwd)[-1] != '/':
18
self.cwd = self.cwd.append_string('/')
23
line = raw_input('%s%s$%s ' % (_boldcode, self.cwd, _normal))
25
command = getattr(self, words[0])
28
except KeyboardInterrupt:
33
print "Error: %s:%s" % (e.__class__.__name__, str(e))
36
new_cwd = self.cwd.resolve_relative(dir)
37
if str(new_cwd)[-1] != '/':
38
new_cwd = new_cwd.append_string('/')
39
if gnomevfs.get_file_info(new_cwd).type != \
40
gnomevfs.FILE_TYPE_DIRECTORY:
41
raise gnomevfs.error('%s is not a directory' % dir)
48
dir = self.cwd.resolve_relative(dir)
50
dhandle = gnomevfs.open_directory(dir)
51
for file_info in dhandle:
55
file = self.cwd.resolve_relative(file)
56
file_info = gnomevfs.get_file_info(file)
57
fp = gnomevfs.open(file, gnomevfs.OPEN_READ)
58
less = os.popen('less -m -F -', 'w')
59
buffer = fp.read(file_info.size)
66
file = self.cwd.resolve_relative(file)
67
file_info = gnomevfs.get_file_info(file, gnomevfs.FILE_INFO_GET_MIME_TYPE)
68
print 'Name: ', file_info.name
71
try: file_type = ('unknown', 'regular', 'directory',
72
'fifo', 'socket', 'chardev', 'blockdev',
73
'symlink')[file_info.type]
75
print 'Type: ', file_type
77
file_size = '(unknown)'
78
try: file_size = file_info.size
80
print 'Size: ', file_size
83
try: mime_type = file_info.mime_type
85
print 'Mime type: ', mime_type
87
if __name__ == '__main__':