Browse Source

Changes to slim for LodelContext - some corrections

prieto 8 years ago
parent
commit
2daf715b61
2 changed files with 25 additions and 11 deletions
  1. 5
    0
      progs/create_instance.sh
  2. 20
    11
      progs/slim/slim.py

+ 5
- 0
progs/create_instance.sh View File

@@ -27,6 +27,11 @@ instdir="$2"
27 27
 libdir="$5"
28 28
 libdir=${libdir:=[@]PKGPYTHONDIR[@]}
29 29
 install_tpl="$3"
30
+
31
+if [ $name == "monosite" ];then
32
+    name=""
33
+fi
34
+
30 35
 if [ -z "$install_tpl" ]
31 36
 then
32 37
 	echo -e "Install template $install_tpl not found.\n" >&2

+ 20
- 11
progs/slim/slim.py View File

@@ -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)

Loading…
Cancel
Save