<commit_before>import os
import sys
from os.path import dirname, join
from django.conf import * 

#configobj
try:
	from configobj import ConfigObj
except:
	#FIXME: ugly
	os.system("apt-get update && apt-get install python-configobj -y")
	from configobj import ConfigObj

cfg = ConfigObj(sys.argv[1]+".cfg")

section = cfg['General']

#Droping the database and recreating

#Preparing command
command =''

if section["user"] != "":
	command+=" --user='"+ section["user"]+"'"
if section["password"] != "":
	command+=" --password='"+ section["password"]+"'"
if section["host"] != "":
	command+=" --host="+ section["host"]
if section["port"] != "":
	command+=" --port="+ section["port"]

command+=" "+section["database"]+" < "+sys.argv[1]

if section["host"] == "":
        host="localhost"
else:
        host=section["host"]

dropDB="mysql -e \"drop database "+section["database"]+"; CREATE DATABASE "+section["database"]+";GRANT ALL ON "+section["database"]+" . * TO '"+section["user"]+"'@'"+host+"';\""+command

print dropDB

if os.system(dropDB)>0:
        sys.exit(1)

importDB="mysql "+command+" < "+sys.argv[1]

print importDB

sys.exit(os.system(importDB))<commit_msg>Issue #104: 'Installation failure: not able to backup database'<commit_after>import os
import sys
from os.path import dirname, join
from django.conf import * 

#configobj
try:
	from configobj import ConfigObj
except:
	#FIXME: ugly
	os.system("apt-get update && apt-get install python-configobj -y")
	from configobj import ConfigObj

cfg = ConfigObj(sys.argv[1]+".cfg")

section = cfg['General']

#Droping the database and recreating

#Preparing command
command = ""
# User must be 'root' in order to successfully backup the database.
command_root = " --user='root' --password"

if section["user"] != "":
	command+=" --user='"+ section["user"]+"'"
if section["password"] != "":
	command+=" --password='"+ section["password"]+"'"
if section["host"] != "":
	command += " --host=" + section["host"]
	command_root += " --host=" + section["host"]
if section["port"] != "":
	command +=" --port=" + section["port"]
	command_root +=" --port=" + section["port"]

command += " " + section["database"] + " < " + sys.argv[1]
command_root += " " + section["database"] + " < " + sys.argv[1]

if section["host"] == "":
        host = "localhost"
else:
        host = section["host"]

# Island Manager will be prompted to enter the root's password for the backup
dropDB = "mysql -e \"drop database " + section["database"] + "; create database " + section["database"] + "; grant all on " + section["database"] + ".* to '" + section["user"] + "'@'" + host + "';\"" + command_root
print dropDB

print "\nPlease input your MySQL root password in order to perform a backup of %s..." % str(section["database"])
if os.system(dropDB)>0:
        sys.exit(1)

importDB = "mysql" + command + " < " + sys.argv[1]
print importDB
sys.exit(os.system(importDB))
{'fraction_non_alphanumeric': 0.20075888237323214, 'fraction_numerical': 0.004829251466022766, 'mean_word_length': 4.631067961165049, 'pattern_counts': {'":': 10, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7587236', 'n_tokens_mistral': 942, 'n_tokens_neox': 930, 'n_words': 256}