Fix: python subprocess.call -> run
This commit is contained in:
@@ -18,41 +18,26 @@ def print_items(list):
|
||||
|
||||
|
||||
def send_unpaid_maestro_mysqldump_to_test_server():
|
||||
'''
|
||||
space = ' '
|
||||
command = 'mysqldump' + space
|
||||
user = '-u root' + space
|
||||
password = '-p52napark!' + space
|
||||
transaction = '--single-transaction' + space
|
||||
db = 'chocomae' + space
|
||||
table = 'maestro' + space
|
||||
where_clause = '--where="DATE(NOW()) - INTERVAL 7 DAY > AcceptClausesDateTime AND ActivateStatus = 0"' + space
|
||||
'''
|
||||
backup_server_address = 'chocomae@test.chocomae.com:'
|
||||
output_directory = '/home/chocomae/unregister-user-backup/'
|
||||
if mode == 'mac':
|
||||
output_directory = ''
|
||||
|
||||
today = datetime.today().strftime('%Y%m%d-%H%M%S')
|
||||
output_filename = today + '.sql'
|
||||
output_fullpath = output_directory + 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"'
|
||||
|
||||
command_mysqldump = 'mysqldump --user=root -passwor=52napark! \
|
||||
--single-transaction chocomae maestro \
|
||||
--where="DATE(NOW()) - INTERVAL 7 DAY > AcceptClausesDateTime AND ActivateStatus = 0" \
|
||||
> ' + output_fullpath
|
||||
command_mysqldump = 'mysqldump --user=root --password=52napark! --single-transaction chocomae maestro'
|
||||
command_mysqldump += ' --where="DATE(NOW()) - INTERVAL 7 DAY > AcceptClausesDateTime AND ActivateStatus = 0" >'
|
||||
command_mysqldump += ' ' + output_fullpath
|
||||
print(command_mysqldump)
|
||||
|
||||
command_scp = 'scp ' + output_fullpath + ' chocomae@test.chocomae.com:' + output_directory
|
||||
command_scp = 'scp '+ output_fullpath + ' chocomae@test.chocomae.com:'
|
||||
command_scp += ' ' + backup_server_address + output_directory
|
||||
print(command_scp)
|
||||
|
||||
if mode == 'mac':
|
||||
return
|
||||
|
||||
subprocess.call(command_mysqldump.split())
|
||||
subprocess.call(command_scp.splite())
|
||||
subprocess.run(command_mysqldump, shell=True, check=True)
|
||||
subprocess.run(command_scp, shell=True, check=True)
|
||||
|
||||
|
||||
# backup unpaid for 7 days maestro list
|
||||
|
||||
Reference in New Issue
Block a user