/[fuse_dbi]/fuse/trunk/python/fuse.py
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /fuse/trunk/python/fuse.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (hide annotations)
Wed Aug 4 11:40:49 2004 UTC (19 years, 8 months ago) by dpavlin
File MIME type: text/x-python
File size: 2491 byte(s)
copy CVS to trunk

1 dpavlin 4 #@+leo-ver=4
2     #@+node:@file fuse.py
3     #
4     # Copyright (C) 2001 Jeff Epler <jepler@unpythonic.dhs.org>
5     #
6     # This program can be distributed under the terms of the GNU GPL.
7     # See the file COPYING.
8     #
9    
10    
11     #@@language python
12     #@+others
13     #@+node:imports
14     # suppress version mismatch warnings
15     try:
16     import warnings
17     warnings.filterwarnings('ignore',
18     'Python C API version mismatch',
19     RuntimeWarning,
20     )
21     except:
22     pass
23    
24     from _fuse import main, DEBUG
25     import os, sys
26     from errno import *
27    
28     #@-node:imports
29     #@+node:class ErrnoWrapper
30     class ErrnoWrapper:
31     #@ @+others
32     #@+node:__init__
33     def __init__(self, func):
34     self.func = func
35     #@-node:__init__
36     #@+node:__call__
37     def __call__(self, *args, **kw):
38     try:
39     return apply(self.func, args, kw)
40     except (IOError, OSError), detail:
41     # Sometimes this is an int, sometimes an instance...
42     if hasattr(detail, "errno"): detail = detail.errno
43     return -detail
44     #@-node:__call__
45     #@-others
46     #@-node:class ErrnoWrapper
47     #@+node:class Fuse
48     class Fuse:
49    
50     #@ @+others
51     #@+node:attribs
52     _attrs = ['getattr', 'readlink', 'getdir', 'mknod', 'mkdir',
53     'unlink', 'rmdir', 'symlink', 'rename', 'link', 'chmod',
54     'chown', 'truncate', 'utime', 'open', 'read', 'write', 'release',
55     'statfs', 'fsync']
56    
57     flags = 0
58     multithreaded = 0
59    
60     #@-node:attribs
61     #@+node:__init__
62     def __init__(self, *args, **kw):
63    
64     # default attributes
65     self.optlist = []
66     self.optdict = {}
67     self.mountpoint = None
68    
69     # grab arguments, if any
70     argv = sys.argv
71     argc = len(argv)
72     if argc > 1:
73     # we've been given the mountpoint
74     self.mountpoint = argv[1]
75     if argc > 2:
76     # we've received mount args
77     optstr = argv[2]
78     opts = optstr.split(",")
79     for o in opts:
80     try:
81     k, v = o.split("=", 1)
82     self.optdict[k] = v
83     except:
84     self.optlist.append(o)
85     #@-node:__init__
86     #@+node:main
87     def main(self):
88     d = {'flags': self.flags}
89     d['multithreaded'] = self.multithreaded
90     for a in self._attrs:
91     if hasattr(self,a):
92     d[a] = ErrnoWrapper(getattr(self, a))
93     apply(main, (), d)
94     #@-node:main
95     #@-others
96     #@-node:class Fuse
97     #@-others
98     #@-node:@file fuse.py
99     #@-leo

  ViewVC Help
Powered by ViewVC 1.1.26