You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2014/09/22 11:23:02 UTC

[2/2] git commit: [#7644] ticket:658 Script to generate a lot of new projects

[#7644] ticket:658 Script to generate a lot of new projects


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/5b619914
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/5b619914
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/5b619914

Branch: refs/heads/je/42cc_7644
Commit: 5b619914878dbfb79c33262795a07d6bb308fa35
Parents: c972fc0
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Sep 19 12:20:49 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Sep 22 10:37:02 2014 +0300

----------------------------------------------------------------------
 scripts/perf/generate-projects.py | 40 ++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5b619914/scripts/perf/generate-projects.py
----------------------------------------------------------------------
diff --git a/scripts/perf/generate-projects.py b/scripts/perf/generate-projects.py
new file mode 100644
index 0000000..0374969
--- /dev/null
+++ b/scripts/perf/generate-projects.py
@@ -0,0 +1,40 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+import re
+from ming.odm import ThreadLocalORMSession
+from allura import model as M
+
+def main(start, cnt):
+    n = M.Neighborhood.query.get(url_prefix='/p/')
+    admin = M.User.by_username('admin1')
+    #M.Project.query.remove({'shortname': re.compile('gen-proj-.*')})
+    #ThreadLocalORMSession.flush_all()
+    for i in range(start, cnt):
+        name = 'gen-proj-{}'.format(i)
+        project = n.register_project(name, admin)
+        if (i-start) > 0 and (i-start) % 100 == 0:
+            print 'Created {} projects'.format(i-start)
+    print 'Flushing...'
+    ThreadLocalORMSession.flush_all()
+    print 'Done'
+
+if __name__ == '__main__':
+    import sys
+    start = int(sys.argv[1])
+    cnt = int(sys.argv[2])
+    main(start, cnt)