Rev 822 | Rev 825 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 822 | Rev 824 | ||
|---|---|---|---|
| Line 242... | Line 242... | ||
| 242 | os.symlink("../" + moddir + "/" + moduleName, localmoddir + "/" + moduleName) |
242 | os.symlink("../" + moddir + "/" + moduleName, localmoddir + "/" + moduleName) |
| 243 | print "Added module successfully" |
243 | print "Added module successfully" |
| 244 | except OSError, (errno, strerror): |
244 | except OSError, (errno, strerror): |
| 245 | if errno == 17: |
245 | if errno == 17: |
| 246 | print "A link, file or directory named " + moduleName + " is already present in the modules directory, not linking" |
246 | print "A link, file or directory named " + moduleName + " is already present in the modules directory, not linking" |
| - | 247 | else: |
|
| - | 248 | raise |
|
| - | 249 | ||
| - | 250 | print "" |
|
| - | 251 | ||
| - | 252 | regenerateModules() |
|
| - | 253 | ||
| - | 254 | ||
| - | 255 | def delModule(moduleName): |
|
| - | 256 | print "Trying to remove module " + moduleName |
|
| - | 257 | ||
| - | 258 | try: |
|
| - | 259 | os.unlink(localmoddir + "/" + moduleName) |
|
| - | 260 | print "Removed module successfully" |
|
| - | 261 | except OSError, (errno, strerror): |
|
| - | 262 | if errno == 2: |
|
| - | 263 | print "No such " + moduleName + " present in the modules directory, not unlinking" |
|
| 247 | else: |
264 | else: |
| 248 | raise |
265 | raise |
| 249 | 266 | ||
| 250 | print "" |
267 | print "" |
| 251 | 268 | ||
| Line 257... | Line 274... | ||
| 257 | print "\t--regenare\t\tRegenarate modules and files" |
274 | print "\t--regenare\t\tRegenarate modules and files" |
| 258 | print "\t--list\t\t\tList avalible modules" |
275 | print "\t--list\t\t\tList avalible modules" |
| 259 | print "\t--help\t\t\tPrint this help" |
276 | print "\t--help\t\t\tPrint this help" |
| 260 | print "\t--add=<module name>\tAdds a module to the application" |
277 | print "\t--add=<module name>\tAdds a module to the application" |
| 261 | print "" |
278 | print "" |
| 262 | 279 | ||
| 263 | 280 | ||
| 264 | def main(): |
281 | def main(): |
| 265 | try: |
282 | try: |
| 266 | opts, args = getopt.getopt(sys.argv[1:], " |
283 | opts, args = getopt.getopt(sys.argv[1:], "hlrd", ["help", "list", "regenerate", "add=", "del="]) |
| 267 | except getopt.GetoptError, err: |
284 | except getopt.GetoptError, err: |
| 268 | # print help information and exit: |
285 | # print help information and exit: |
| 269 | print str(err) # will print something like "option -a not recognized" |
286 | print str(err) # will print something like "option -a not recognized" |
| 270 | usage() |
287 | usage() |
| 271 | sys.exit(2) |
288 | sys.exit(2) |
| 272 | 289 | ||
| 273 | for o, a in opts: |
290 | for o, a in opts: |
| 274 | if o in ("-l", "--list"): |
291 | if o in ("-l", "--list"): |
| 275 | print getModules() |
292 | print getModules() |
| - | 293 | ||
| 276 | elif o in ("-h", "--help"): |
294 | elif o in ("-h", "--help"): |
| 277 | usage() |
295 | usage() |
| 278 | sys.exit() |
296 | sys.exit() |
| - | 297 | ||
| 279 | elif o in ("-r", "--regenerate"): |
298 | elif o in ("-r", "--regenerate"): |
| 280 | regenerateModules() |
299 | regenerateModules() |
| - | 300 | ||
| 281 | elif o in ("--add"): |
301 | elif o in ("--add"): |
| 282 | if len(a) == 0: |
302 | if len(a) == 0: |
| 283 | print "No modulename specified" |
303 | print "No modulename specified" |
| 284 | usage() |
304 | usage() |
| 285 | sys.exit() |
305 | sys.exit() |
| 286 | 306 | ||
| 287 | if a not in getModules(): |
307 | if a not in getModules(): |
| 288 | print a + " is not a recognized module name" |
308 | print a + " is not a recognized module name" |
| 289 | sys.exit() |
309 | sys.exit() |
| 290 | 310 | ||
| 291 | addModule(a) |
311 | addModule(a) |
| - | 312 | ||
| - | 313 | elif o in ("--del"): |
|
| - | 314 | if len(a) == 0: |
|
| - | 315 | print "No modulename specified" |
|
| - | 316 | usage() |
|
| - | 317 | sys.exit() |
|
| - | 318 | ||
| - | 319 | if a not in getModules(): |
|
| - | 320 | print a + " is not a recognized module name" |
|
| - | 321 | sys.exit() |
|
| - | 322 | ||
| - | 323 | delModule(a) |
|
| - | 324 | ||
| 292 | else: |
325 | else: |
| 293 | assert False, "unhandled option" |
326 | assert False, "unhandled option" |
| 294 | 327 | ||
| 295 | 328 | ||
| 296 | if __name__ == "__main__": |
329 | if __name__ == "__main__": |