"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "bin/make-database" between
viewvc-1.1.28.tar.gz and viewvc-1.2.1.tar.gz

About: ViewVC is a browser interface for CVS and Subversion version control repositories.

make-database  (viewvc-1.1.28):make-database  (viewvc-1.2.1)
skipping to change at line 18 skipping to change at line 18
# distribution or at http://viewvc.org/license-1.html. # distribution or at http://viewvc.org/license-1.html.
# #
# For more information, visit http://viewvc.org/ # For more information, visit http://viewvc.org/
# #
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# #
# administrative program for CVSdb; creates a clean database in # administrative program for CVSdb; creates a clean database in
# MySQL 3.22 or later # MySQL 3.22 or later
# #
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
#
# INSTALL-TIME CONFIGURATION
#
# These values will be set during the installation process. During
# development, they will remain None.
#
LIBRARY_DIR = None
CONF_PATHNAME = None
# Adjust sys.path to include our library directory
import sys
import os
if LIBRARY_DIR:
sys.path.insert(0, LIBRARY_DIR)
else:
sys.path.insert(0, os.path.abspath(os.path.join(sys.argv[0], "../../lib")))
import os, sys, string
import popen2
import getopt import getopt
if sys.hexversion >= 0x3030000:
import subprocess
subprocess.has_timeout = True
else:
try:
import subprocess32 as subprocess
subprocess.has_timeout = True
except ImportError:
import subprocess
subprocess.has_timeout = False
if sys.version_info[0] >= 3:
def raw_input(prompt=''):
return input(prompt)
## ------------------------------------------------------------------------ ## ------------------------------------------------------------------------
## Stuff common to all schemas ## Stuff common to all schemas
## ##
DATABASE_SCRIPT_COMMON="""\ DATABASE_SCRIPT_COMMON="""\
DROP DATABASE IF EXISTS <dbname>; DROP DATABASE IF EXISTS <dbname>;
CREATE DATABASE <dbname>; CREATE DATABASE <dbname>;
USE <dbname>; USE <dbname>;
""" """
skipping to change at line 48 skipping to change at line 79
CREATE TABLE branches ( CREATE TABLE branches (
id mediumint(9) NOT NULL auto_increment, id mediumint(9) NOT NULL auto_increment,
branch varchar(64) binary DEFAULT '' NOT NULL, branch varchar(64) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE branch (branch) UNIQUE branch (branch)
) ENGINE=MyISAM; ) ENGINE=MyISAM;
DROP TABLE IF EXISTS checkins; DROP TABLE IF EXISTS checkins;
CREATE TABLE checkins ( CREATE TABLE checkins (
type enum('Change','Add','Remove'), type enum('Change','Add','Remove'),
ci_when datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, ci_when datetime DEFAULT '1000-01-01 00:00:00' NOT NULL,
whoid mediumint(9) DEFAULT '0' NOT NULL, whoid mediumint(9) DEFAULT '0' NOT NULL,
repositoryid mediumint(9) DEFAULT '0' NOT NULL, repositoryid mediumint(9) DEFAULT '0' NOT NULL,
dirid mediumint(9) DEFAULT '0' NOT NULL, dirid mediumint(9) DEFAULT '0' NOT NULL,
fileid mediumint(9) DEFAULT '0' NOT NULL, fileid mediumint(9) DEFAULT '0' NOT NULL,
revision varchar(32) binary DEFAULT '' NOT NULL, revision varchar(32) binary DEFAULT '' NOT NULL,
stickytag varchar(255) binary DEFAULT '' NOT NULL, stickytag varchar(255) binary DEFAULT '' NOT NULL,
branchid mediumint(9) DEFAULT '0' NOT NULL, branchid mediumint(9) DEFAULT '0' NOT NULL,
addedlines int(11) DEFAULT '0' NOT NULL, addedlines int(11) DEFAULT '0' NOT NULL,
removedlines int(11) DEFAULT '0' NOT NULL, removedlines int(11) DEFAULT '0' NOT NULL,
descid mediumint(9), descid mediumint(9),
skipping to change at line 140 skipping to change at line 171
CREATE TABLE branches ( CREATE TABLE branches (
id mediumint(9) NOT NULL auto_increment, id mediumint(9) NOT NULL auto_increment,
branch varchar(64) binary DEFAULT '' NOT NULL, branch varchar(64) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE branch (branch) UNIQUE branch (branch)
) ENGINE=MyISAM; ) ENGINE=MyISAM;
DROP TABLE IF EXISTS commits; DROP TABLE IF EXISTS commits;
CREATE TABLE commits ( CREATE TABLE commits (
type enum('Change','Add','Remove'), type enum('Change','Add','Remove'),
ci_when datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, ci_when datetime DEFAULT '1000-01-01 00:00:00' NOT NULL,
whoid mediumint(9) DEFAULT '0' NOT NULL, whoid mediumint(9) DEFAULT '0' NOT NULL,
repositoryid mediumint(9) DEFAULT '0' NOT NULL, repositoryid mediumint(9) DEFAULT '0' NOT NULL,
dirid mediumint(9) DEFAULT '0' NOT NULL, dirid mediumint(9) DEFAULT '0' NOT NULL,
fileid mediumint(9) DEFAULT '0' NOT NULL, fileid mediumint(9) DEFAULT '0' NOT NULL,
revision varchar(32) binary DEFAULT '' NOT NULL, revision varchar(32) binary DEFAULT '' NOT NULL,
stickytag varchar(255) binary DEFAULT '' NOT NULL, stickytag varchar(255) binary DEFAULT '' NOT NULL,
branchid mediumint(9) DEFAULT '0' NOT NULL, branchid mediumint(9) DEFAULT '0' NOT NULL,
addedlines int(11) DEFAULT '0' NOT NULL, addedlines int(11) DEFAULT '0' NOT NULL,
removedlines int(11) DEFAULT '0' NOT NULL, removedlines int(11) DEFAULT '0' NOT NULL,
descid mediumint(9), descid mediumint(9),
skipping to change at line 265 skipping to change at line 296
[Default: ViewVC] [Default: ViewVC]
--help Show this usage message. --help Show this usage message.
--hostname=ARG Use ARG as the hostname for the MySQL connection. --hostname=ARG Use ARG as the hostname for the MySQL connection.
--port=ARG Use ARG as the port for the MySQL connection. --port=ARG Use ARG as the port for the MySQL connection.
--password=ARG Use ARG as the password for the MySQL connection. --password=ARG Use ARG as the password for the MySQL connection.
--timeout=ARG Use ARG as the timeout in sec for waiting MySQL
to create database if timeout feature is available.
[Default: 300]
--username=ARG Use ARG as the username for the MySQL connection. --username=ARG Use ARG as the username for the MySQL connection.
--version=ARG Create the database using the schema employed by --version=ARG Create the database using the schema employed by
version ARG of ViewVC. Valid values are: version ARG of ViewVC. Valid values are:
[ "1.0" ] [ "1.0" ]
""" % (os.path.basename(sys.argv[0]))) """ % (os.path.basename(sys.argv[0])))
if errmsg is not None: if errmsg is not None:
stream.write("[ERROR] %s.\n" % (errmsg)) stream.write("[ERROR] %s.\n" % (errmsg))
sys.exit(1) sys.exit(1)
sys.exit(0) sys.exit(0)
if __name__ == "__main__": if __name__ == "__main__":
try: try:
# Parse the command-line options, if any. # Parse the command-line options, if any.
dbname = version = hostname = port = username = password = None dbname = version = hostname = port = username = password = None
timeout = 300
opts, args = getopt.getopt(sys.argv[1:], '', [ 'dbname=', opts, args = getopt.getopt(sys.argv[1:], '', [ 'dbname=',
'help', 'help',
'hostname=', 'hostname=',
'port=', 'port=',
'password=', 'password=',
'username=', 'username=',
'version=', 'version=',
'timeout=',
]) ])
if len(args) > 0: if len(args) > 0:
usage_and_exit("Unexpected command-line parameters") usage_and_exit("Unexpected command-line parameters")
for name, value in opts: for name, value in opts:
if name == '--help': if name == '--help':
usage_and_exit(0) usage_and_exit(0)
elif name == '--dbname': elif name == '--dbname':
dbname = value dbname = value
elif name == '--hostname': elif name == '--hostname':
hostname = value hostname = value
skipping to change at line 309 skipping to change at line 346
port = value port = value
elif name == '--username': elif name == '--username':
username = value username = value
elif name == '--password': elif name == '--password':
password = value password = value
elif name == '--version': elif name == '--version':
if value in ["1.0"]: if value in ["1.0"]:
version = value version = value
else: else:
usage_and_exit("Invalid version specified") usage_and_exit("Invalid version specified")
elif subprocess.has_timeout and name == '--timeout':
timeout = int(value)
# Prompt for information not provided via command-line options. # Prompt for information not provided via command-line options.
if hostname is None: if hostname is None:
hostname = raw_input("MySQL Hostname (leave blank for default): ") hostname = raw_input("MySQL Hostname (leave blank for default): ")
if port is None: if port is None:
port = raw_input("MySQL Port (leave blank for default): ") port = raw_input("MySQL Port (leave blank for default): ")
if username is None: if username is None:
username = raw_input("MySQL User: ") username = raw_input("MySQL User: ")
if password is None: if password is None:
password = raw_input("MySQL Password: ") password = raw_input("MySQL Password: ")
if dbname is None: if dbname is None:
dbname = raw_input("ViewVC Database Name [default: ViewVC]: ") or "ViewVC" dbname = raw_input("ViewVC Database Name [default: ViewVC]: ") or "ViewVC"
# Create the database. # Create the database.
dscript = string.replace(DATABASE_SCRIPT_COMMON, "<dbname>", dbname) dscript = DATABASE_SCRIPT_COMMON.replace("<dbname>", dbname)
if version == "1.0": if version == "1.0":
print BONSAI_COMPAT print(BONSAI_COMPAT)
dscript = dscript + DATABASE_SCRIPT_VERSION_0 dscript = dscript + DATABASE_SCRIPT_VERSION_0
else: else:
dscript = dscript + DATABASE_SCRIPT_VERSION_1 dscript = dscript + DATABASE_SCRIPT_VERSION_1
# Calculate command arguments. # Calculate command arguments.
cmd_args = "--user=%s --password=%s" % (username, password) cmd_args = [("--user=%s" % username), ("--password=%s" % password)]
if hostname or port: if hostname or port:
cmd_args = cmd_args + " --protocol=TCP" cmd_args.append("--protocol=TCP")
if hostname: if hostname:
cmd_args = cmd_args + " --host=%s" % (hostname) cmd_args.append("--host=%s" % hostname)
if port: if port:
cmd_args = cmd_args + " --port=%s" % (port) cmd_args.append("--port=%s" % port)
if sys.platform == "win32": cmd = ["mysql"]
cmd = "mysql %s" % (cmd_args) mysql = subprocess.Popen(cmd + cmd_args, bufsize=-1, stdin=subprocess.PIPE,
mysql = os.popen(cmd, "w") # popen2.Popen3 is not provided on windows stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
mysql.write(dscript) universal_newlines=True,
status = mysql.close() close_fds=(sys.platform != "win32"))
if (subprocess.has_timeout):
try:
stdout_data = mysql.communicate(input=dscript, timeout=timeout)[0]
status = mysql.returncode
except subprocess.TimeoutExpired:
mysql.kill()
stdout_data = mysql.communicate()[0]
stdout_data += '\n[ERROR] Timeout expired while calling mysql process'
status = -1
else: else:
cmd = "{ mysql %s ; } 2>&1" % (cmd_args) stdout_data = mysql.communicate(input=dscript)[0]
pipes = popen2.Popen3(cmd) status = mysql.returncode
pipes.tochild.write(dscript) print(stdout_data)
pipes.tochild.close()
print pipes.fromchild.read()
status = pipes.wait()
if status: if status:
print "[ERROR] The database did not create sucessfully." print("[ERROR] The database did not create sucessfully.")
sys.exit(1) sys.exit(1)
print "Database created successfully. Don't forget to configure the " print("Database created successfully. Don't forget to configure the ")
print "[cvsdb] section of your viewvc.conf file." print("[cvsdb] section of your viewvc.conf file.")
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
sys.exit(0) sys.exit(0)
 End of changes. 19 change blocks. 
25 lines changed or deleted 69 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)