Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes for Python 3 compatibility #13008

Merged
merged 4 commits into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Tools/px4moduledoc/srcparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import re
import math
import textwrap
from functools import reduce


class ModuleDocumentation(object):
"""
Expand Down
1 change: 1 addition & 0 deletions Tools/setup/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pyserial>=3.0
pyulog>=0.5.0
pyyaml
setuptools>=39.2.0
six>=1.12.0
toml>=0.9
tornado
wheel>=0.31.1
1 change: 0 additions & 1 deletion Tools/uorb_graph/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import json



parser = argparse.ArgumentParser(
description='Generate uORB pub/sub dependency graph from source code')

Expand Down
9 changes: 2 additions & 7 deletions Tools/upload_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from __future__ import print_function

from argparse import ArgumentParser
from six.moves import input
import subprocess
import sys


try:
import requests
except:
Expand All @@ -38,12 +38,7 @@ def ask_value(text, default=None):
if default != None:
ask_string += ' (Press ENTER to use ' + default + ')'
ask_string += ': '

if sys.version_info[0] < 3:
ret = raw_input(ask_string)
else:
ret = input(ask_string)

ret = input(ask_string).strip()
if ret == "" and default != None:
return default
return ret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from mavros_msgs.msg import AttitudeTarget
from mavros_test_common import MavrosTestCommon
from pymavlink import mavutil
from six.moves import xrange
from std_msgs.msg import Header
from threading import Thread
from tf.transformations import quaternion_from_euler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from geometry_msgs.msg import PoseStamped, Quaternion
from mavros_test_common import MavrosTestCommon
from pymavlink import mavutil
from six.moves import xrange
from std_msgs.msg import Header
from threading import Thread
from tf.transformations import quaternion_from_euler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
WaypointPush
from pymavlink import mavutil
from sensor_msgs.msg import NavSatFix
from six.moves import xrange


class MavrosTestCommon(unittest.TestCase):
Expand Down
1 change: 1 addition & 0 deletions integrationtests/python_src/px4_it/mavros/mission_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from mavros_msgs.msg import Mavlink, Waypoint, WaypointReached
from mavros_test_common import MavrosTestCommon
from pymavlink import mavutil
from six.moves import xrange
from threading import Thread


Expand Down
17 changes: 12 additions & 5 deletions msg/tools/generate_microRTPS_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
except ImportError:
raise ImportError(
"Failed to import yaml. You may need to install it with 'sudo pip install pyyaml'")
try:
from six.moves import input
except ImportError:
try:
input = raw_input # Python 2
except NameError:
pass # Python 3


def check_rtps_id_uniqueness(classifier):
Expand Down Expand Up @@ -281,19 +288,19 @@ def check_rtps_id_uniqueness(classifier):

if del_tree:
if agent:
_continue = str(raw_input("\nFiles in " + agent_out_dir +
" will be erased, continue?[Y/n]\n"))
if _continue == "N" or _continue == "n":
_continue = str(input("\nFiles in " + agent_out_dir +
" will be erased, continue?[Y/n]\n"))
if _continue.strip() in ("N", "n"):
print("Aborting execution...")
exit(-1)
else:
if agent and os.path.isdir(agent_out_dir):
shutil.rmtree(agent_out_dir)

if client:
_continue = str(raw_input(
_continue = str(input(
"\nFiles in " + client_out_dir + " will be erased, continue?[Y/n]\n"))
if _continue == "N" or _continue == "n":
if _continue.strip() in ("N", "n"):
print("Aborting execution...")
exit(-1)
else:
Expand Down
1 change: 1 addition & 0 deletions msg/tools/uorb_rtps_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import sys
import os
import argparse
import errno
import yaml
import re
import difflib
Expand Down
12 changes: 4 additions & 8 deletions msg/tools/uorb_to_ros_rtps_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
Script to read an yaml file containing the RTPS message IDs and update the naming convention to PascalCase
"""

import errno
import os
import yaml
import sys
import argparse
import six

__author__ = 'PX4 Development Team'
__copyright__ = \
Expand Down Expand Up @@ -91,14 +93,8 @@ def update_dict(list):
if verbose:
num_of_msgs = 0
for i, dictionary in enumerate(list["rtps"]):
# implementation depends on the Python version being used
if sys.version_info[0] < 3:
dict = {k: v.title().replace('_', '') if isinstance(
v, basestring) else v for k, v in dictionary.iteritems()}
else:
dict = {k: v.title().replace('_', '') if isinstance(
v, str) else v for k, v in dictionary.items()}
list["rtps"][i] = dict
list["rtps"][i] = {k: v.title().replace('_', '') if isinstance(
v, six.string_types) else v for k, v in six.iteritems(dictionary)}
if verbose:
num_of_msgs += 1
if verbose:
Expand Down
Loading