Repository: incubator-airflow Updated Branches: refs/heads/v1-9-test bee823c6c -> 95813dec0
[AIRFLOW-1664] write file as binary instead of str Closes #2649 from jgao54/write-binary (cherry picked from commit 95a4136a134cdf4210ee1bc078dd93c620386c91) Signed-off-by: Bolke de Bruin <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/95813dec Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/95813dec Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/95813dec Branch: refs/heads/v1-9-test Commit: 95813dec05371c3ab7e3e178af214028b9ac6502 Parents: bee823c Author: Joy Gao <[email protected]> Authored: Sat Sep 30 08:28:10 2017 +0200 Committer: Bolke de Bruin <[email protected]> Committed: Sat Sep 30 08:28:28 2017 +0200 ---------------------------------------------------------------------- airflow/contrib/operators/mysql_to_gcs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/95813dec/airflow/contrib/operators/mysql_to_gcs.py ---------------------------------------------------------------------- diff --git a/airflow/contrib/operators/mysql_to_gcs.py b/airflow/contrib/operators/mysql_to_gcs.py index c8ebcd0..f94bc24 100644 --- a/airflow/contrib/operators/mysql_to_gcs.py +++ b/airflow/contrib/operators/mysql_to_gcs.py @@ -122,7 +122,7 @@ class MySqlToGoogleCloudStorageOperator(BaseOperator): """ schema = list(map(lambda schema_tuple: schema_tuple[0], cursor.description)) file_no = 0 - tmp_file_handle = NamedTemporaryFile(mode='w', delete=True) + tmp_file_handle = NamedTemporaryFile(delete=True) tmp_file_handles = {self.filename.format(file_no): tmp_file_handle} for row in cursor: @@ -139,7 +139,7 @@ class MySqlToGoogleCloudStorageOperator(BaseOperator): # Stop if the file exceeds the file size limit. if tmp_file_handle.tell() >= self.approx_max_file_size_bytes: file_no += 1 - tmp_file_handle = NamedTemporaryFile(mode='w', delete=True) + tmp_file_handle = NamedTemporaryFile(delete=True) tmp_file_handles[self.filename.format(file_no)] = tmp_file_handle return tmp_file_handles @@ -169,7 +169,7 @@ class MySqlToGoogleCloudStorageOperator(BaseOperator): }) self.log.info('Using schema for %s: %s', self.schema_filename, schema) - tmp_schema_file_handle = NamedTemporaryFile(mode='w', delete=True) + tmp_schema_file_handle = NamedTemporaryFile(delete=True) json.dump(schema, tmp_schema_file_handle) return {self.schema_filename: tmp_schema_file_handle}
