Changeset 438
- Timestamp:
- 05/07/08 09:54:40
(8 months ago)
- Author:
- mgoldman
- Message:
Merged changes to manager.py into the new style argument handling.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r437 |
r438 |
|
| 131 | 131 | ### returns the response from the server. |
|---|
| 132 | 132 | def handlestorage(mgr, cmd, argv): |
|---|
| 133 | | useage = 'useage:\n ' + cmd + " FILE GROUP" |
|---|
| | 133 | useage = 'useage:\n ' + cmd + " GROUP FILE" |
|---|
| 134 | 134 | if(len(argv) < 2): |
|---|
| 135 | 135 | print useage |
|---|
| 136 | 136 | sys.exit(1) |
|---|
| | 137 | resp = m.query_server(m.list_groups()) |
|---|
| | 138 | if argv[0] not in resp.body: |
|---|
| | 139 | print 'Group \'' + argv[0] + '\' does not exist' |
|---|
| | 140 | sys.exit(1) |
|---|
| 137 | 141 | if cmd == 'add': |
|---|
| 138 | | if not os.path.exists(argv[0]): |
|---|
| 139 | | print 'File \'' + argv[0] + '\' does not exist' |
|---|
| 140 | | print 'moduole addition not yet implemented' |
|---|
| | 142 | files = [] |
|---|
| | 143 | for arg in argv[1:]: |
|---|
| | 144 | if not os.path.exists(arg): |
|---|
| | 145 | print 'File \'' + arg + '\' does not exist' |
|---|
| | 146 | else: |
|---|
| | 147 | files.append((os.path.realpath(os.path.expanduser(arg))), file_util.checksum(arg)) |
|---|
| | 148 | if len(files) != len(argv[1:]): |
|---|
| | 149 | sys.exit(1) |
|---|
| | 150 | msg = m.add_message(argv[0]) |
|---|
| | 151 | msg.body[1] += files |
|---|
| 141 | 152 | elif cmd == 'remove': |
|---|
| 142 | | print 'module removal not yet implemented' |
|---|
| 143 | | return None |
|---|
| | 153 | files = [os.path.basename(x) for x in argv[1:]] |
|---|
| | 154 | msg = m.remove_message(argv[0]) |
|---|
| | 155 | msg.body[1] += files |
|---|
| | 156 | else: |
|---|
| | 157 | print "unknown command" |
|---|
| | 158 | print useage |
|---|
| | 159 | sys.exit(1) |
|---|
| | 160 | return mgr.query_server(msg) |
|---|
| 144 | 161 | |
|---|
| 145 | 162 | def handleupdate(mgr, argv): |
|---|
| … | … | |
| 216 | 233 | if cmd == 'add' or cmd == 'remove': |
|---|
| 217 | 234 | res = handlestorage(m, cmd, sys.argv[2:]) |
|---|
| 218 | | #if cmd == 'add': |
|---|
| 219 | | # if arg1 == '' or arg2 == '': |
|---|
| 220 | | # print 'usage:' |
|---|
| 221 | | # print ' add GROUP FILE...' |
|---|
| 222 | | # sys.exit(1) |
|---|
| 223 | | # resp = m.query_server(m.list_groups()) |
|---|
| 224 | | # if arg1 not in resp.body: |
|---|
| 225 | | # print 'Group \'' + arg1 + '\' does not exist' |
|---|
| 226 | | # sys.exit(1) |
|---|
| 227 | | # files = [] |
|---|
| 228 | | # for arg in sys.argv[3:]: |
|---|
| 229 | | # if not os.path.exists(arg): |
|---|
| 230 | | # print 'File \'' + arg + '\' does not exist' |
|---|
| 231 | | # else: |
|---|
| 232 | | # files.append((os.path.realpath(os.path.expanduser(arg))), file_util.checksum(arg)) |
|---|
| 233 | | # if len(files) != len(sys.argv[3:]): |
|---|
| 234 | | # sys.exit(1) |
|---|
| 235 | | # msg = m.add_message(arg1) |
|---|
| 236 | | # msg.body[1] += files |
|---|
| 237 | | #elif cmd == 'remove': |
|---|
| 238 | | # if arg1 == '' or arg2 == '': |
|---|
| 239 | | # print 'usage:' |
|---|
| 240 | | # print ' remove GROUP FILE...' |
|---|
| 241 | | # sys.exit(1) |
|---|
| 242 | | # resp = m.query_server(m.list_groups()) |
|---|
| 243 | | # if arg1 not in resp.body: |
|---|
| 244 | | # print 'Group \'' + arg1 + '\' does not exist' |
|---|
| 245 | | # sys.exit(1) |
|---|
| 246 | | # files = [os.path.basename(x) for x in sys.argv[3:]] |
|---|
| 247 | | # msg = m.remove_message(arg1) |
|---|
| 248 | | # msg.body[1] += files |
|---|
| 249 | 235 | elif cmd == 'update': |
|---|
| 250 | 236 | res = handleupdate(m, sys.argv[2:]) |
|---|
Download in other formats:
* Generating other formats may take time.