Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0A8D8200BCE for ; Fri, 2 Dec 2016 20:46:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 090F0160B24; Fri, 2 Dec 2016 19:46:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2B240160B08 for ; Fri, 2 Dec 2016 20:46:04 +0100 (CET) Received: (qmail 4388 invoked by uid 500); 2 Dec 2016 19:46:03 -0000 Mailing-List: contact commits-help@airflow.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.incubator.apache.org Delivered-To: mailing list commits@airflow.incubator.apache.org Received: (qmail 4379 invoked by uid 99); 2 Dec 2016 19:46:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Dec 2016 19:46:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id DE152180286 for ; Fri, 2 Dec 2016 19:46:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id MX_5_6LORhBY for ; Fri, 2 Dec 2016 19:46:00 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id C47505FBEE for ; Fri, 2 Dec 2016 19:45:59 +0000 (UTC) Received: (qmail 3353 invoked by uid 99); 2 Dec 2016 19:45:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Dec 2016 19:45:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id B5D0C2C2A6D for ; Fri, 2 Dec 2016 19:45:58 +0000 (UTC) Date: Fri, 2 Dec 2016 19:45:58 +0000 (UTC) From: "Rafael Gomes Fernandes (JIRA)" To: commits@airflow.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AIRFLOW-668) Configuration parsing doesn't work properly with python 3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 02 Dec 2016 19:46:05 -0000 [ https://issues.apache.org/jira/browse/AIRFLOW-668?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Rafael Gomes Fernandes updated AIRFLOW-668: ------------------------------------------- Description: The problem is: if you use python3 and the '_cmd' on the config file airflow will not start due the error: {noformat} File "~/test/env/airflow3/lib/python3.4/site-packages/airflow/configuration.py", line 447, in _validate "sqlite" in self.get('core', 'sql_alchemy_conn')): TypeError: 'str' does not support the buffer interface {noformat} To reproduce the problem change the following line on airflow.cfg: {code:title=airflow.cfgborderStyle=solid} sql_alchemy_conn_cmd = echo sqlite:////~/airflow/airflow.db {code} The solution is change the following run_command method's line on configuration.py: {code:title=airflow/configuration.py|borderStyle=solid} def run_command(command): """ Runs command and returns stdout """ process = subprocess.Popen( command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE{color:green}, universal_newlines=True{color}) output, stderr = process.communicate() if process.returncode != 0: raise AirflowConfigException( "Cannot execute {}. Error code is: {}. Output: {}, Stderr: {}" .format(command, process.returncode, output, stderr) ) return output {code} By setting the universal_newlines to true the file objects stdout and stderr are opened as text files and treated as string in python 2 and python 3 avoiding the error. run_command with universal_newlines=True: When using python 3 output type: and no error. When using python 2 output type: and no error. run_command as it is : When using python 3 output type: and TypeError. When using python 2 output type: and no error. was: The problem is: if you use python3 and the '_cmd' on the config file airflow will not start due the error: File "~/test/env/airflow3/lib/python3.4/site-packages/airflow/configuration.py", line 447, in _validate "sqlite" in self.get('core', 'sql_alchemy_conn')): TypeError: 'str' does not support the buffer interface To reproduce the problem change the following line on airflow.cfg: sql_alchemy_conn_cmd = echo sqlite:////~/airflow/airflow.db The solution is change the following run_command method's line on configuration.py: command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) By setting the universal_newlines to true the file objects stdout and stderr are opened as text files and treated as string in python 2 and python 3 avoiding the error. run_command with universal_newlines=True: When using python 3 output type: and no error. When using python 2 output type: and no error. run_command as it is : When using python 3 output type: and TypeError. When using python 2 output type: and no error. > Configuration parsing doesn't work properly with python 3 > --------------------------------------------------------- > > Key: AIRFLOW-668 > URL: https://issues.apache.org/jira/browse/AIRFLOW-668 > Project: Apache Airflow > Issue Type: Bug > Environment: Airflow version: v1.7.1.3 > - Airflow components: webserver and scheduler with a postgres database and CeleryExecutor > - Python Version: 3.4.5 > Reporter: Rafael Gomes Fernandes > Assignee: Rafael Gomes Fernandes > > The problem is: if you use python3 and the '_cmd' on the config file airflow will not start due the error: > {noformat} > File "~/test/env/airflow3/lib/python3.4/site-packages/airflow/configuration.py", line 447, in _validate > "sqlite" in self.get('core', 'sql_alchemy_conn')): > TypeError: 'str' does not support the buffer interface > {noformat} > To reproduce the problem change the following line on airflow.cfg: > {code:title=airflow.cfgborderStyle=solid} > sql_alchemy_conn_cmd = echo sqlite:////~/airflow/airflow.db > {code} > The solution is change the following run_command method's line on configuration.py: > {code:title=airflow/configuration.py|borderStyle=solid} > def run_command(command): > """ > Runs command and returns stdout > """ > process = subprocess.Popen( > command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE{color:green}, universal_newlines=True{color}) > output, stderr = process.communicate() > if process.returncode != 0: > raise AirflowConfigException( > "Cannot execute {}. Error code is: {}. Output: {}, Stderr: {}" > .format(command, process.returncode, output, stderr) > ) > return output > {code} > By setting the universal_newlines to true the file objects stdout and stderr are opened as text files and treated as string in python 2 and python 3 avoiding the error. > run_command with universal_newlines=True: > When using python 3 output type: and no error. > When using python 2 output type: and no error. > run_command as it is : > When using python 3 output type: and TypeError. > When using python 2 output type: and no error. -- This message was sent by Atlassian JIRA (v6.3.4#6332)