Fix: subprocess.call argument to array
This commit is contained in:
@@ -18,6 +18,7 @@ def print_items(list):
|
||||
|
||||
|
||||
def send_unpaid_maestro_mysqldump_to_test_server():
|
||||
'''
|
||||
space = ' '
|
||||
command = 'mysqldump' + space
|
||||
user = '-u root' + space
|
||||
@@ -26,21 +27,42 @@ def send_unpaid_maestro_mysqldump_to_test_server():
|
||||
db = 'chocomae' + space
|
||||
table = 'maestro' + space
|
||||
where_clause = '--where="DATE(NOW()) - INTERVAL 7 DAY > AcceptClausesDateTime AND ActivateStatus = 0"' + space
|
||||
'''
|
||||
output_directory = '/home/chocomae/unregister-user-backup/'
|
||||
if mode == 'mac':
|
||||
output_directory = ''
|
||||
today = datetime.today().strftime('%Y%m%d-%H%M%S')
|
||||
output_filename = '> ' + output_directory + today + '.sql'
|
||||
output_filename = today + '.sql'
|
||||
output_fullpath = output_directory + output_filename
|
||||
|
||||
command_db_backup = command + user + password + transaction + db + table + where_clause + output_filename
|
||||
# command_db_backup = command + user + password + transaction + db + table + where_clause + output_filename
|
||||
# 'mysqldump -u "${DBUSER}" -p"${DBPASS}" --single-transaction "${DBNAME}" "${filename}"
|
||||
# --where="DATE(${record_date})=CURDATE()" > "${filename}.dump.bydate.sql"'
|
||||
if mode == 'mac':
|
||||
print(command_db_backup)
|
||||
else:
|
||||
subprocess.call(command_db_backup)
|
||||
|
||||
command_mysqldump = []
|
||||
command_mysqldump.append('mysql')
|
||||
command_mysqldump.append('-u')
|
||||
command_mysqldump.append('root')
|
||||
command_mysqldump.append('-p52napark!')
|
||||
command_mysqldump.append('--single-transaction')
|
||||
command_mysqldump.append('chocomae')
|
||||
command_mysqldump.append('maestro')
|
||||
command_mysqldump.append('--where="DATE(NOW()) - INTERVAL 7 DAY > AcceptClausesDateTime AND ActivateStatus = 0"')
|
||||
command_mysqldump.append('>')
|
||||
command_mysqldump.append(output_fullpath)
|
||||
print(command_mysqldump)
|
||||
|
||||
command_scp = []
|
||||
command_scp.append('scp')
|
||||
command_scp.append(output_fullpath)
|
||||
backup_server_address = 'chocomae@test.chocomae.com:'
|
||||
command_scp = 'scp' + space + output_filename + space + backup_server_address + output_directory
|
||||
command_scp.append(backup_server_address + output_directory)
|
||||
print(command_scp)
|
||||
|
||||
if mode == 'mac':
|
||||
return
|
||||
|
||||
subprocess.call(command_mysqldump)
|
||||
subprocess.call(command_scp)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user