Skip to content
Browse files

Script to mass-set ai passwords, for stresstesting

  • Loading branch information...
1 parent 9f5a875 commit 3b8ec069553f6bf5f26706ff689284741abfac86 @dripton committed
Showing with 42 additions and 0 deletions.
  1. +41 −0 bin/set-all-slugathon-ai-passwords
  2. +1 −0 setup.py
View
41 bin/set-all-slugathon-ai-passwords
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+
+__copyright__ = "Copyright (c) 2003-2012 David Ripton"
+__license__ = "GNU GPL v2"
+
+
+"""Set all ai passwords to the passed-in value."""
+
+import argparse
+import tempfile
+import os
+
+from slugathon.util import prefs
+
+
+def set_ai_passwords(passwd_path, password):
+ """Set all passwords for users ai* in file password_path to password."""
+ fil = open(passwd_path)
+ with tempfile.NamedTemporaryFile(prefix="slugathon", suffix="passwd",
+ delete=False) as tmp_file:
+ for line in fil:
+ if line.startswith("ai"):
+ user, passwd = line.strip().split(":", 1)
+ tmp_file.write("%s:%s\n" % (user, password))
+ else:
+ tmp_file.write(line)
+ os.rename(tmp_file.name, passwd_path)
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-a", "--password", action="store", type=str,
+ default="ai", help="password to set for each ai")
+ parser.add_argument("--passwd-path", action="store", type=str,
+ default=prefs.passwd_path(), help="path to passwd file")
+ args = parser.parse_args()
+ set_ai_passwords(args.passwd_path, args.password)
+
+
+if __name__ == "__main__":
+ main()
View
1 setup.py
@@ -91,6 +91,7 @@ def write_version_file():
scripts=[
"bin/slugathon",
"bin/stresstest-slugathon",
+ "bin/set-all-slugathon-ai-passwords",
],
classifiers=[
"Development Status :: 3 - Alpha",

0 comments on commit 3b8ec06

Please sign in to comment.
Something went wrong with that request. Please try again.