Skip to content

Commit

Permalink
[AIRFLOW-4201] Replace unicode strings by normal strings (apache#5026)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjiajie authored and Fokko committed Apr 30, 2019
1 parent 7e2a807 commit 1e74a94
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 63 deletions.
4 changes: 2 additions & 2 deletions airflow/_vendor/nvd3/NVD3Chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def __init__(self, **kwargs):
self.htmlheader = ''
#: Place holder for the graph (the HTML div)
#: Written by ``buildcontainer``
self.container = u''
self.container = ''
#: Header for javascript code
self.containerheader = u''
self.containerheader = ''
# CDN http://cdnjs.com/libraries/nvd3/ needs to make sure it's up to
# date
self.header_css = [
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# 'on_failure_callback': some_function,
# 'on_success_callback': some_other_function,
# 'on_retry_callback': another_function,
# 'trigger_rule': u'all_success'
# 'trigger_rule': 'all_success'
}

dag = DAG(
Expand Down
2 changes: 1 addition & 1 deletion dev/airflow-license
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _licenses = {'MIT': ['Permission is hereby granted free of charge', 'The above c

def get_notices():
license_file = open("../LICENSE", "r")
regex = ur"\((.+?)\) (.+?) \((http.+?)\)"
regex = r"\((.+?)\) (.+?) \((http.+?)\)"

return list(filter(None, [re.findall(regex, line) for line in license_file]))

Expand Down
2 changes: 1 addition & 1 deletion dev/airflow-pr
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, local):
if primary_author == "":
primary_author = distinct_authors[0]

merge_message_flags.append(u'--author="{}"'.format(primary_author))
merge_message_flags.append('--author="{}"'.format(primary_author))

else:
# This will mark the PR as merged
Expand Down
16 changes: 8 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
master_doc = 'index'

# General information about the project.
project = u'Airflow'
# copyright = u''
project = 'Airflow'
# copyright = ''

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -344,8 +344,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'Airflow.tex', u'Airflow Documentation',
u'Apache Airflow', 'manual'),
('index', 'Airflow.tex', 'Airflow Documentation',
'Apache Airflow', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -374,8 +374,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'airflow', u'Airflow Documentation',
[u'Apache Airflow'], 1)
('index', 'airflow', 'Airflow Documentation',
['Apache Airflow'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -388,8 +388,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [(
'index', 'Airflow', u'Airflow Documentation',
u'Apache Airflow', 'Airflow',
'index', 'Airflow', 'Airflow Documentation',
'Apache Airflow', 'Airflow',
'Airflow is a system to programmaticaly author, schedule and monitor data pipelines.',
'Miscellaneous'
), ]
Expand Down
2 changes: 1 addition & 1 deletion docs/howto/write-logs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ example:
*** Reading remote log from gs://<bucket where logs should be persisted>/example_bash_operator/run_this_last/2017-10-03T00:00:00/16.log.
[2017-10-03 21:57:50,056] {cli.py:377} INFO - Running on host chrisr-00532
[2017-10-03 21:57:50,093] {base_task_runner.py:115} INFO - Running: ['bash', '-c', u'airflow run example_bash_operator run_this_last 2017-10-03T00:00:00 --job_id 47 --raw -sd DAGS_FOLDER/example_dags/example_bash_operator.py']
[2017-10-03 21:57:50,093] {base_task_runner.py:115} INFO - Running: ['bash', '-c', 'airflow run example_bash_operator run_this_last 2017-10-03T00:00:00 --job_id 47 --raw -sd DAGS_FOLDER/example_dags/example_bash_operator.py']
[2017-10-03 21:57:51,264] {base_task_runner.py:98} INFO - Subtask: [2017-10-03 21:57:51,263] {__init__.py:45} INFO - Using executor SequentialExecutor
[2017-10-03 21:57:51,306] {base_task_runner.py:98} INFO - Subtask: [2017-10-03 21:57:51,306] {models.py:186} INFO - Filling up the DagBag from /airflow/dags/example_dags/example_bash_operator.py
Expand Down
6 changes: 3 additions & 3 deletions tests/contrib/hooks/test_sqoop_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ def setUp(self):
@patch('subprocess.Popen')
def test_popen(self, mock_popen):
# Given
mock_popen.return_value.stdout = StringIO(u'stdout')
mock_popen.return_value.stderr = StringIO(u'stderr')
mock_popen.return_value.stdout = StringIO('stdout')
mock_popen.return_value.stderr = StringIO('stderr')
mock_popen.return_value.returncode = 0
mock_popen.return_value.communicate.return_value = \
[StringIO(u'stdout\nstdout'), StringIO(u'stderr\nstderr')]
[StringIO('stdout\nstdout'), StringIO('stderr\nstderr')]

# When
hook = SqoopHook(conn_id='sqoop_test')
Expand Down
6 changes: 3 additions & 3 deletions tests/contrib/operators/test_dataproc_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def test_cluster_name_log_sub(self):
setattr(dataproc_task, 'cluster_name', rendered)
with self.assertRaises(TypeError):
dataproc_task.execute(None)
mock_info.assert_called_with('Creating cluster: %s', u'smoke-cluster-testnodash')
mock_info.assert_called_with('Creating cluster: %s', 'smoke-cluster-testnodash')

def test_build_cluster_data_internal_ip_only_without_subnetwork(self):

Expand Down Expand Up @@ -457,7 +457,7 @@ def test_cluster_name_log_sub(self):
setattr(dataproc_task, 'cluster_name', rendered)
with self.assertRaises(TypeError):
dataproc_task.execute(None)
mock_info.assert_called_with('Scaling cluster: %s', u'smoke-cluster-testnodash')
mock_info.assert_called_with('Scaling cluster: %s', 'smoke-cluster-testnodash')


class DataprocClusterDeleteOperatorTest(unittest.TestCase):
Expand Down Expand Up @@ -518,7 +518,7 @@ def test_cluster_name_log_sub(self):
with self.assertRaises(TypeError):
dataproc_task.execute(None)
mock_info.assert_called_with('Deleting cluster: %s',
u'smoke-cluster-testnodash')
'smoke-cluster-testnodash')


class DataProcHadoopOperatorTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/operators/test_mongo_to_s3_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_render_template(self):
ti = TaskInstance(self.mock_operator, DEFAULT_DATE)
ti.render_templates()

expected_rendered_template = {'$lt': u'2017-01-01T00:00:00+00:00Z'}
expected_rendered_template = {'$lt': '2017-01-01T00:00:00+00:00Z'}

self.assertDictEqual(
expected_rendered_template,
Expand Down
12 changes: 6 additions & 6 deletions tests/contrib/operators/test_spark_submit_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ def test_render_template(self):
ti.render_templates()

# Then
expected_application_args = [u'-f', 'foo',
u'--bar', 'bar',
u'--start', (DEFAULT_DATE - timedelta(days=1))
expected_application_args = ['-f', 'foo',
'--bar', 'bar',
'--start', (DEFAULT_DATE - timedelta(days=1))
.strftime("%Y-%m-%d"),
u'--end', DEFAULT_DATE.strftime("%Y-%m-%d"),
u'--with-spaces',
u'args should keep embdedded spaces',
'--end', DEFAULT_DATE.strftime("%Y-%m-%d"),
'--with-spaces',
'args should keep embdedded spaces',
]
expected_name = "spark_submit_job"
self.assertListEqual(expected_application_args,
Expand Down
4 changes: 2 additions & 2 deletions tests/contrib/utils/test_sendgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ def setUp(self):
self.cc = ['[email protected]', '[email protected]']
self.bcc = ['[email protected]', '[email protected]']
self.expected_mail_data = {
'content': [{'type': u'text/html', 'value': self.html_content}],
'content': [{'type': 'text/html', 'value': self.html_content}],
'personalizations': [
{'cc': [{'email': '[email protected]'}, {'email': '[email protected]'}],
'to': [{'email': '[email protected]'}, {'email': '[email protected]'}],
'bcc': [{'email': '[email protected]'}, {'email': '[email protected]'}]}],
'from': {'email': u'[email protected]'},
'from': {'email': '[email protected]'},
'subject': 'sendgrid-send-email unit test',
'mail_settings': {},
}
Expand Down
57 changes: 28 additions & 29 deletions tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def test_bash_operator(self):
def test_bash_operator_multi_byte_output(self):
t = BashOperator(
task_id='test_multi_byte_bash_operator',
bash_command=u"echo \u2600",
bash_command="echo \u2600",
dag=self.dag,
output_encoding='utf-8')
t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)
Expand Down Expand Up @@ -612,7 +612,7 @@ def test_template_with_json_variable_as_value(self):

def verify_templated_field(context):
self.assertEqual(context['ti'].task.some_templated_field,
u'{"foo": "bar"}')
'{"foo": "bar"}')

t = OperatorSubclass(
task_id='test_complex_template',
Expand Down Expand Up @@ -967,10 +967,9 @@ def test_run_command(self):

cmd = 'import sys; {0}; sys.stdout.flush()'.format(write)

self.assertEqual(run_command("python -c '{0}'".format(cmd)),
u'\u1000foo')
self.assertEqual(run_command("python -c '{0}'".format(cmd)), '\u1000foo')

self.assertEqual(run_command('echo "foo bar"'), u'foo bar\n')
self.assertEqual(run_command('echo "foo bar"'), 'foo bar\n')
self.assertRaises(AirflowConfigException, run_command, 'bash -c "exit 1"')

def test_trigger_dagrun_with_execution_date(self):
Expand Down Expand Up @@ -1972,123 +1971,123 @@ def ls(self, path, include_toplevel=False):
return []
elif path[0] == '/datadirectory/datafile':
return [{
'group': u'supergroup',
'group': 'supergroup',
'permission': 420,
'file_type': 'f',
'access_time': 1481122343796,
'block_replication': 3,
'modification_time': 1481122343862,
'length': 0,
'blocksize': 134217728,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/datafile'
}]
elif path[0] == '/datadirectory/empty_directory' and include_toplevel:
return [{
'group': u'supergroup',
'group': 'supergroup',
'permission': 493,
'file_type': 'd',
'access_time': 0,
'block_replication': 0,
'modification_time': 1481132141540,
'length': 0,
'blocksize': 0,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/empty_directory'
}]
elif path[0] == '/datadirectory/not_empty_directory' and include_toplevel:
return [{
'group': u'supergroup',
'group': 'supergroup',
'permission': 493,
'file_type': 'd',
'access_time': 0,
'block_replication': 0,
'modification_time': 1481132141540,
'length': 0,
'blocksize': 0,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/empty_directory'
}, {
'group': u'supergroup',
'group': 'supergroup',
'permission': 420,
'file_type': 'f',
'access_time': 1481122343796,
'block_replication': 3,
'modification_time': 1481122343862,
'length': 0,
'blocksize': 134217728,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/not_empty_directory/test_file'
}]
elif path[0] == '/datadirectory/not_empty_directory':
return [{
'group': u'supergroup',
'group': 'supergroup',
'permission': 420,
'file_type': 'f',
'access_time': 1481122343796,
'block_replication': 3,
'modification_time': 1481122343862,
'length': 0,
'blocksize': 134217728,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/not_empty_directory/test_file'
}]
elif path[0] == '/datadirectory/not_existing_file_or_directory':
raise FakeSnakeBiteClientException
elif path[0] == '/datadirectory/regex_dir':
return [{
'group': u'supergroup',
'group': 'supergroup',
'permission': 420,
'file_type': 'f',
'access_time': 1481122343796,
'block_replication': 3,
'modification_time': 1481122343862, 'length': 12582912,
'blocksize': 134217728,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/regex_dir/test1file'
}, {
'group': u'supergroup',
'group': 'supergroup',
'permission': 420,
'file_type': 'f',
'access_time': 1481122343796,
'block_replication': 3,
'modification_time': 1481122343862,
'length': 12582912,
'blocksize': 134217728,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/regex_dir/test2file'
}, {
'group': u'supergroup',
'group': 'supergroup',
'permission': 420,
'file_type': 'f',
'access_time': 1481122343796,
'block_replication': 3,
'modification_time': 1481122343862,
'length': 12582912,
'blocksize': 134217728,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/regex_dir/test3file'
}, {
'group': u'supergroup',
'group': 'supergroup',
'permission': 420,
'file_type': 'f',
'access_time': 1481122343796,
'block_replication': 3,
'modification_time': 1481122343862,
'length': 12582912,
'blocksize': 134217728,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/regex_dir/copying_file_1.txt._COPYING_'
}, {
'group': u'supergroup',
'group': 'supergroup',
'permission': 420,
'file_type': 'f',
'access_time': 1481122343796,
'block_replication': 3,
'modification_time': 1481122343862,
'length': 12582912,
'blocksize': 134217728,
'owner': u'hdfs',
'owner': 'hdfs',
'path': '/datadirectory/regex_dir/copying_file_3.txt.sftp'
}]
else:
Expand Down Expand Up @@ -2286,8 +2285,8 @@ def test_send_smtp(self, mock_send_mime):
self.assertEqual('subject', msg['Subject'])
self.assertEqual(configuration.conf.get('smtp', 'SMTP_MAIL_FROM'), msg['From'])
self.assertEqual(2, len(msg.get_payload()))
filename = u'attachment; filename="' + os.path.basename(attachment.name) + '"'
self.assertEqual(filename, msg.get_payload()[-1].get(u'Content-Disposition'))
filename = 'attachment; filename="' + os.path.basename(attachment.name) + '"'
self.assertEqual(filename, msg.get_payload()[-1].get('Content-Disposition'))
mimeapp = MIMEApplication('attachment')
self.assertEqual(mimeapp.get_payload(), msg.get_payload()[-1].get_payload())

Expand All @@ -2314,8 +2313,8 @@ def test_send_bcc_smtp(self, mock_send_mime):
self.assertEqual('subject', msg['Subject'])
self.assertEqual(configuration.conf.get('smtp', 'SMTP_MAIL_FROM'), msg['From'])
self.assertEqual(2, len(msg.get_payload()))
self.assertEqual(u'attachment; filename="' + os.path.basename(attachment.name) + '"',
msg.get_payload()[-1].get(u'Content-Disposition'))
self.assertEqual('attachment; filename="' + os.path.basename(attachment.name) + '"',
msg.get_payload()[-1].get('Content-Disposition'))
mimeapp = MIMEApplication('attachment')
self.assertEqual(mimeapp.get_payload(), msg.get_payload()[-1].get_payload())

Expand Down
2 changes: 1 addition & 1 deletion tests/hooks/test_hive_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_load_df(self, mock_to_csv, mock_load_file):
assert mock_load_file.call_count == 1
kwargs = mock_load_file.call_args[1]
self.assertEqual(kwargs["delimiter"], delimiter)
self.assertEqual(kwargs["field_dict"], {"c": u"STRING"})
self.assertEqual(kwargs["field_dict"], {"c": "STRING"})
self.assertTrue(isinstance(kwargs["field_dict"], OrderedDict))
self.assertEqual(kwargs["table"], table)

Expand Down
Loading

0 comments on commit 1e74a94

Please sign in to comment.