382 """ |
382 """ |
383 name = 'newcube' |
383 name = 'newcube' |
384 arguments = '<cubename>' |
384 arguments = '<cubename>' |
385 |
385 |
386 options = ( |
386 options = ( |
|
387 ("directory", |
|
388 {'short': 'd', 'type' : 'string', 'metavar': '<cubes directory>', |
|
389 'help': 'directory where the new cube should be created', |
|
390 } |
|
391 ), |
387 ("verbose", |
392 ("verbose", |
388 {'short': 'v', 'type' : 'yn', 'metavar': '<verbose>', |
393 {'short': 'v', 'type' : 'yn', 'metavar': '<verbose>', |
389 'default': 'n', |
394 'default': 'n', |
390 'help': 'verbose mode: will ask all possible configuration questions', |
395 'help': 'verbose mode: will ask all possible configuration questions', |
391 } |
396 } |
416 raise BadCommandUsage("exactly one argument (cube name) is expected") |
421 raise BadCommandUsage("exactly one argument (cube name) is expected") |
417 cubename, = args |
422 cubename, = args |
418 #if ServerConfiguration.mode != "dev": |
423 #if ServerConfiguration.mode != "dev": |
419 # self.fail("you can only create new cubes in development mode") |
424 # self.fail("you can only create new cubes in development mode") |
420 verbose = self.get('verbose') |
425 verbose = self.get('verbose') |
421 cubedir = ServerConfiguration.CUBES_DIR |
426 cubesdir = self.get('directory') |
422 if not isdir(cubedir): |
427 if not cubedir: |
423 print "creating apps directory", cubedir |
428 cubespath = ServerConfiguration.cubes_path() |
|
429 if len(cubespath) > 1: |
|
430 raise BadCommandUsage("can't guess directory where to put the new cube." |
|
431 " Please specify it using the --directory option") |
|
432 cubesdir = cubespath[0] |
|
433 if not isdir(cubesdir): |
|
434 print "creating cubes directory", cubesdir |
424 try: |
435 try: |
425 mkdir(cubedir) |
436 mkdir(cubesdir) |
426 except OSError, err: |
437 except OSError, err: |
427 self.fail("failed to create directory %r\n(%s)" % (cubedir, err)) |
438 self.fail("failed to create directory %r\n(%s)" % (cubedir, err)) |
428 cubedir = join(cubedir, cubename) |
439 cubedir = join(cubesdir, cubename) |
429 if exists(cubedir): |
440 if exists(cubedir): |
430 self.fail("%s already exists !" % (cubedir)) |
441 self.fail("%s already exists !" % (cubedir)) |
431 skeldir = join(BASEDIR, 'skeleton') |
442 skeldir = join(BASEDIR, 'skeleton') |
432 if verbose: |
443 if verbose: |
433 distname = raw_input('Debian name for your cube (just type enter to use the cube name): ').strip() |
444 distname = raw_input('Debian name for your cube (just type enter to use the cube name): ').strip() |