Skip to content

Commit

Permalink
Apply changes from pull request 244; Update to include sftp storage
Browse files Browse the repository at this point in the history
  • Loading branch information
pkkid committed Feb 23, 2018
1 parent 1d373fb commit 1a2ad99
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dbbackup/db/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"""
import os
import shlex
from django.core.files.base import ContentFile
from storages.backends.sftpstorage import SFTPStorageFile
from tempfile import SpooledTemporaryFile
from subprocess import Popen
from subprocess import Popen, PIPE
from importlib import import_module
from dbbackup import settings, utils
from . import exceptions
Expand Down Expand Up @@ -135,8 +137,11 @@ def run_command(self, command, stdin=None, env=None):
full_env.update(self.env)
full_env.update(env or {})
try:
process = Popen(cmd, stdin=stdin, stdout=stdout, stderr=stderr,
env=full_env)
if isinstance(stdin, (ContentFile, SFTPStorageFile)):
process = Popen(cmd, stdin=PIPE, stdout=stdout, stderr=stderr, env=full_env)
process.communicate(input=stdin.read())
else:
process = Popen(cmd, stdin=stdin, stdout=stdout, stderr=stderr, env=full_env)
process.wait()
if process.poll():
stderr.seek(0)
Expand Down

0 comments on commit 1a2ad99

Please sign in to comment.