From 2da95ade5343148daeb224099134da9c23b4bd57 Mon Sep 17 00:00:00 2001 From: Pratyush Mittal Date: Sat, 15 Mar 2014 16:00:37 +0530 Subject: [PATCH] Made Python3 compatible --- mysql-ramdisk.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mysql-ramdisk.py b/mysql-ramdisk.py index d606503..e7a4df5 100755 --- a/mysql-ramdisk.py +++ b/mysql-ramdisk.py @@ -117,7 +117,7 @@ def calc_ramdisk_size(num_megabytes): def create_ramdisk(ramdisk_size, disk_path=settings.RAMDISK_PATH): - print 'Creating ramdisk...' + print('Creating ramdisk...') if is_linux(): size_in_mb = ramdisk_size * 512 / 1048576 # TODO: What if dir already exists? Destroy data? @@ -129,7 +129,7 @@ def create_ramdisk(ramdisk_size, disk_path=settings.RAMDISK_PATH): stdout=PIPE, shell=True).communicate()[0] Popen('diskutil eraseVolume HFS+ ramdisk %s' % disk_path, stdout=PIPE, shell=True).communicate() - print 'Done creating ramdisk: %s' % disk_path + print('Done creating ramdisk: %s' % disk_path) def kill_ramdisk(path_to_ramdisk): @@ -137,23 +137,23 @@ def kill_ramdisk(path_to_ramdisk): if is_linux(): # TODO: # make this use path_to_ramdisk. - print "Unmounting ramdisk '%s'." % path_to_ramdisk + print("Unmounting ramdisk '%s'." % path_to_ramdisk) # Nonzero return codes are bad. Wouldn't want to accidently remove rm anything # other than the ramdisk. if call(['sudo umount %s' % path_to_ramdisk], shell=True): raise Exception("Unmounting of ramdisk at '%s' failed." \ % path_to_ramdisk) - print "Deleting ramdisk '%s'." % path_to_ramdisk + print("Deleting ramdisk '%s'." % path_to_ramdisk) call(['sudo rm -rf %s' % path_to_ramdisk], shell=True) else: - print Popen(('hdiutil detach %s' % path_to_ramdisk), stdout=PIPE, - shell=True).communicate()[0] + print(Popen(('hdiutil detach %s' % path_to_ramdisk), stdout=PIPE, + shell=True).communicate()[0]) def install_db(path_to_ramdisk=None): # TODO support other dbs? - print 'Installing new db...' + print('Installing new db...') if is_linux(): call(['/usr/bin/mysql_install_db ' '--user=mysql ' @@ -166,13 +166,13 @@ def install_db(path_to_ramdisk=None): '--basedir=/usr/local/mysql ' '--datadir=/Volumes/ramdisk', shell=True) p.communicate() - print 'Done installing db.' + print('Done installing db.' ) def start_db(path_to_ramdisk=None): # TODO support other dbs? # TODO make it more configurable? - print 'Starting db...' + print('Starting db...') if is_linux(): call(['sudo mysqld ' '--basedir=/usr ' @@ -183,7 +183,7 @@ def start_db(path_to_ramdisk=None): '--port=3308 ' '--socket=/tmp/mysql.ramdisk.sock &' % ((path_to_ramdisk,) * 3)], stdout=PIPE, shell=True) - print "To log into mysql use: 'msyql --socket=/tmp/mysql.ramdisk.sock [OPTIONS]'" + print("To log into mysql use: 'msyql --socket=/tmp/mysql.ramdisk.sock [OPTIONS]'") else: p = Popen('/usr/local/mysql/bin/mysqld ' '--basedir=/usr/local/mysql ' @@ -194,7 +194,7 @@ def start_db(path_to_ramdisk=None): '--port=3308 ' '--socket=/tmp/mysql.sock &', stdout=PIPE, shell=True) p.communicate() - print 'Done starting db.' + print('Done starting db.') if __name__ == "__main__": main()