| Rev | Line | |
|---|
| [4247] | 1 | """ |
|---|
| 2 | generic utilities needed for the RepositoryHookSystem package; |
|---|
| 3 | ideally, these would be part of python's stdlib, but until then, |
|---|
| 4 | roll one's own |
|---|
| 5 | """ |
|---|
| 6 | |
|---|
| 7 | import os |
|---|
| 8 | import subprocess |
|---|
| 9 | import sys |
|---|
| 10 | |
|---|
| 11 | def iswritable(filename): |
|---|
| 12 | """ |
|---|
| 13 | returns whether or not a filename is writable, |
|---|
| 14 | irregardless of its existance |
|---|
| 15 | """ |
|---|
| 16 | |
|---|
| 17 | if os.path.exists(filename): |
|---|
| 18 | return os.access(filename, os.W_OK) |
|---|
| 19 | else: |
|---|
| 20 | |
|---|
| 21 | # XXX try to make the file and delete it, |
|---|
| 22 | # as this is easier than figuring out permissions |
|---|
| 23 | try: |
|---|
| 24 | file(filename, 'w').close() |
|---|
| 25 | except IOError: |
|---|
| 26 | return False |
|---|
| 27 | |
|---|
| 28 | os.remove(filename) # remove the file stub |
|---|
| 29 | return True |
|---|
| 30 | |
|---|
| 31 | def command_line_args(string): |
|---|
| 32 | p = subprocess.Popen('%s %s %s' % (sys.executable, |
|---|
| 33 | os.path.abspath(__file__), |
|---|
| 34 | string), |
|---|
| 35 | shell=True, stdout=subprocess.PIPE) |
|---|
| 36 | stdout = p.communicate()[0] |
|---|
| 37 | args = stdout.split('\n')[:-1] |
|---|
| 38 | return args |
|---|
| 39 | |
|---|
| 40 | if __name__ == '__main__': |
|---|
| 41 | for i in sys.argv[1:]: |
|---|
| 42 | print i |
|---|
Note: See
TracBrowser
for help on using the repository browser.