+ return user.Info(name, uid, gid, realname, homedir, console)
+
+class MysqlStrategy(install.Strategy):
+ """
+ Performs scripts specific guesses for MySQL variables. This
+ may create an appropriate database for the user.
+ """
+ side_effects = True
+ provides = frozenset(["dsn"])
+ def prepare(self):
+ """Uses the SQL programs in the scripts locker"""
+ if self.application.database != "mysql":
+ raise install.StrategyFailed
+ try:
+ self._triplet = shell.eval("/mit/scripts/sql/bin/get-password").split()
+ except shell.CallError:
+ raise install.StrategyFailed
+ if len(self._triplet) != 3:
+ raise install.StrategyFailed
+ self._username = os.getenv('USER')
+ if self._username is None:
+ raise install.StrategyFailed
+ def execute(self, options):
+ """Creates a new database for the user using ``get-next-database`` and ``create-database``."""
+ host, username, password = self._triplet
+ # race condition
+ name = shell.eval("/mit/scripts/sql/bin/get-next-database", os.path.basename(self.dir))
+ database = shell.eval("/mit/scripts/sql/bin/create-database", name)
+ options.dsn = sqlalchemy.engine.url.URL("mysql", username=username, password=password, host=host, database=database)
+
+class EmailStrategy(install.Strategy):
+ """Performs script specific guess for email."""
+ provides = frozenset(["email"])
+ def prepare(self):
+ """Uses :envvar:`USER` and assumes you are an MIT affiliate."""
+ # XXX: This might be buggy, because locker might be set to USER
+ self._user = os.getenv("USER")
+ if self._user is None:
+ raise install.StrategyFailed
+ def execute(self, options):
+ """No-op."""
+ options.email = self._user + "@mit.edu"