Skip to content

Commit 8bdca0d

Browse files
author
sql.mit.edu project
committed
Switch to null-terminated strings
1 parent 7bb7869 commit 8bdca0d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

mysqlshow.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env python
22

3+
from __future__ import print_function
34
import MySQLdb
45

56
db = MySQLdb.connect(read_default_file='~/.my.cnf')
67
cursor = db.cursor()
78
cursor.execute('SHOW DATABASES')
89
for (database,) in cursor:
9-
print database
10+
print(database, end='\0')

run-afs.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ while [ $kstartret -ne 0 ]; do
2626
# If we get here, we're under both the lock and the k5start
2727

2828
# Get a list of all the mysql databases
29-
for db in $(mysqlshow.py); do
29+
mysqlshow.py | while read -d $'\0' db; do
3030
# Make sure the database is in the form username+db
3131
echo "$db" | grep -q '+'
3232
[ $? -ne 0 ] && continue
3333
# Figure out the size
34-
size=$(du -s /srv/data/mysql/db/$(mysqlname "$db") | awk '{print $1}')
34+
size=$(du -s ${base}/$(mysqlname "$db") | awk '{print $1}')
3535
[ $size -gt $max_size ] && echo "Skipping $db" && continue
3636
user="${db%%+*}"
3737
sql-backup.py --local -c sql.mit.edu-afs.json --user="$user" --database="$db"

sql-backup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def main():
5454
(options, args) = parser.parse_args()
5555

5656
# Uncomment this to make -v actually work
57-
#logger.setLevel(logging.INFO if options.verbose else
58-
# logging.WARNING)
57+
logger.setLevel(logging.INFO if options.verbose else
58+
logging.WARNING)
5959

6060
logger.debug(options)
6161

0 commit comments

Comments
 (0)