|
@@ -166,22 +166,31 @@ lower&upper alphanum and '_'. Name '%s' is invalid" % name)
|
166
|
166
|
##@brief Create a new instance
|
167
|
167
|
#@param name str : the instance name
|
168
|
168
|
def new_instance(name):
|
169
|
|
- name_is_valid(name)
|
170
|
|
- store_datas = get_store_datas()
|
171
|
|
- if name in store_datas:
|
172
|
|
- logging.error("A site named '%s' already exists" % name)
|
173
|
|
- exit(1)
|
174
|
|
- if LodelContext._type == LodelContext.MONOSITE and len(store_datas) > 0:
|
175
|
|
- logging.error("We are in monosite mode and a site already exists")
|
176
|
|
- exit(1)
|
|
169
|
+ if LodelContext._type == LodelContext.MONOSITE:
|
|
170
|
+ store_datas = get_store_datas()
|
|
171
|
+ if len(store_datas) > 0:
|
|
172
|
+ logging.error("We are in monosite mode and a site already exists")
|
|
173
|
+ exit(1)
|
|
174
|
+ if name is not None:
|
|
175
|
+ logging.error("We are in monosite mode, we can't have a site name")
|
|
176
|
+ exit(1)
|
|
177
|
+ instance_path = INSTANCES_ABSPATH
|
|
178
|
+ else:
|
|
179
|
+ name_is_valid(name)
|
|
180
|
+ store_datas = get_store_datas()
|
|
181
|
+ if name in store_datas:
|
|
182
|
+ logging.error("A site named '%s' already exists" % name)
|
|
183
|
+ exit(1)
|
|
184
|
+ instance_path = os.path.join(INSTANCES_ABSPATH, name)
|
|
185
|
+
|
177
|
186
|
if not os.path.isdir(INSTANCES_ABSPATH):
|
178
|
187
|
logging.info("Sites directory '%s' doesn't exist, creating it" % INSTANCES_ABSPATH)
|
179
|
188
|
os.mkdir(INSTANCES_ABSPATH)
|
180
|
|
- instance_path = os.path.join(INSTANCES_ABSPATH, name)
|
|
189
|
+ sitename = name if name is not None else 'monosite'
|
181
|
190
|
creation_cmd = '{script} "{name}" "{path}" "{install_tpl}" \
|
182
|
|
-"{emfile}"'.format(
|
|
191
|
+ "{emfile}"'.format(
|
183
|
192
|
script = CREATION_SCRIPT,
|
184
|
|
- name = name,
|
|
193
|
+ name = sitename,
|
185
|
194
|
path = instance_path,
|
186
|
195
|
install_tpl = INSTALL_TPL,
|
187
|
196
|
emfile = EMFILE)
|