allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/2] git commit: [#7644] ticket:658 Script to generate a lot of new projects
Date Mon, 22 Sep 2014 18:14:28 GMT
Repository: allura
Updated Branches:
  refs/heads/master ba2f82de6 -> e3316fda2


[#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/8c803cd0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/8c803cd0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/8c803cd0

Branch: refs/heads/master
Commit: 8c803cd02edb38601e20c74085f8515453f438d0
Parents: ba2f82d
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Sep 19 12:20:49 2014 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Sep 22 18:14:14 2014 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/8c803cd0/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)


Mime
View raw message