id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
249,300 | JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py | bounds_overlap | def bounds_overlap(bound1, bound2):
'''return true if two bounding boxes overlap'''
(x1,y1,w1,h1) = bound1
(x2,y2,w2,h2) = bound2
if x1+w1 < x2:
return False
if x2+w2 < x1:
return False
if y1+h1 < y2:
return False
if y2+h2 < y1:
return False
return True | python | def bounds_overlap(bound1, bound2):
'''return true if two bounding boxes overlap'''
(x1,y1,w1,h1) = bound1
(x2,y2,w2,h2) = bound2
if x1+w1 < x2:
return False
if x2+w2 < x1:
return False
if y1+h1 < y2:
return False
if y2+h2 < y1:
return False
return True | [
"def",
"bounds_overlap",
"(",
"bound1",
",",
"bound2",
")",
":",
"(",
"x1",
",",
"y1",
",",
"w1",
",",
"h1",
")",
"=",
"bound1",
"(",
"x2",
",",
"y2",
",",
"w2",
",",
"h2",
")",
"=",
"bound2",
"if",
"x1",
"+",
"w1",
"<",
"x2",
":",
"return",
... | return true if two bounding boxes overlap | [
"return",
"true",
"if",
"two",
"bounding",
"boxes",
"overlap"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py#L132-L144 |
249,301 | JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py | latlon_to_grid | def latlon_to_grid(latlon):
'''convert to grid reference'''
from MAVProxy.modules.lib.ANUGA import redfearn
(zone, easting, northing) = redfearn.redfearn(latlon[0], latlon[1])
if latlon[0] < 0:
hemisphere = 'S'
else:
hemisphere = 'N'
return UTMGrid(zone, easting, northing, hemisp... | python | def latlon_to_grid(latlon):
'''convert to grid reference'''
from MAVProxy.modules.lib.ANUGA import redfearn
(zone, easting, northing) = redfearn.redfearn(latlon[0], latlon[1])
if latlon[0] < 0:
hemisphere = 'S'
else:
hemisphere = 'N'
return UTMGrid(zone, easting, northing, hemisp... | [
"def",
"latlon_to_grid",
"(",
"latlon",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"lib",
".",
"ANUGA",
"import",
"redfearn",
"(",
"zone",
",",
"easting",
",",
"northing",
")",
"=",
"redfearn",
".",
"redfearn",
"(",
"latlon",
"[",
"0",
"]",
","... | convert to grid reference | [
"convert",
"to",
"grid",
"reference"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py#L189-L197 |
249,302 | JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py | latlon_round | def latlon_round(latlon, spacing=1000):
'''round to nearest grid corner'''
g = latlon_to_grid(latlon)
g.easting = (g.easting // spacing) * spacing
g.northing = (g.northing // spacing) * spacing
return g.latlon() | python | def latlon_round(latlon, spacing=1000):
'''round to nearest grid corner'''
g = latlon_to_grid(latlon)
g.easting = (g.easting // spacing) * spacing
g.northing = (g.northing // spacing) * spacing
return g.latlon() | [
"def",
"latlon_round",
"(",
"latlon",
",",
"spacing",
"=",
"1000",
")",
":",
"g",
"=",
"latlon_to_grid",
"(",
"latlon",
")",
"g",
".",
"easting",
"=",
"(",
"g",
".",
"easting",
"//",
"spacing",
")",
"*",
"spacing",
"g",
".",
"northing",
"=",
"(",
"... | round to nearest grid corner | [
"round",
"to",
"nearest",
"grid",
"corner"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py#L199-L204 |
249,303 | JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py | wxToPIL | def wxToPIL(wimg):
'''convert a wxImage to a PIL Image'''
from PIL import Image
(w,h) = wimg.GetSize()
d = wimg.GetData()
pimg = Image.new("RGB", (w,h), color=1)
pimg.fromstring(d)
return pimg | python | def wxToPIL(wimg):
'''convert a wxImage to a PIL Image'''
from PIL import Image
(w,h) = wimg.GetSize()
d = wimg.GetData()
pimg = Image.new("RGB", (w,h), color=1)
pimg.fromstring(d)
return pimg | [
"def",
"wxToPIL",
"(",
"wimg",
")",
":",
"from",
"PIL",
"import",
"Image",
"(",
"w",
",",
"h",
")",
"=",
"wimg",
".",
"GetSize",
"(",
")",
"d",
"=",
"wimg",
".",
"GetData",
"(",
")",
"pimg",
"=",
"Image",
".",
"new",
"(",
"\"RGB\"",
",",
"(",
... | convert a wxImage to a PIL Image | [
"convert",
"a",
"wxImage",
"to",
"a",
"PIL",
"Image"
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py#L207-L214 |
249,304 | JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py | child_close_fds | def child_close_fds():
'''close file descriptors that a child process should not inherit.
Should be called from child processes.'''
global child_fd_list
import os
while len(child_fd_list) > 0:
fd = child_fd_list.pop(0)
try:
os.close(fd)
except Exception as msg:... | python | def child_close_fds():
'''close file descriptors that a child process should not inherit.
Should be called from child processes.'''
global child_fd_list
import os
while len(child_fd_list) > 0:
fd = child_fd_list.pop(0)
try:
os.close(fd)
except Exception as msg:... | [
"def",
"child_close_fds",
"(",
")",
":",
"global",
"child_fd_list",
"import",
"os",
"while",
"len",
"(",
"child_fd_list",
")",
">",
"0",
":",
"fd",
"=",
"child_fd_list",
".",
"pop",
"(",
"0",
")",
"try",
":",
"os",
".",
"close",
"(",
"fd",
")",
"exce... | close file descriptors that a child process should not inherit.
Should be called from child processes. | [
"close",
"file",
"descriptors",
"that",
"a",
"child",
"process",
"should",
"not",
"inherit",
".",
"Should",
"be",
"called",
"from",
"child",
"processes",
"."
] | 303b18992785b2fe802212f2d758a60873007f1f | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_util.py#L256-L266 |
249,305 | spaam/svtplay-dl | scripts/cibuild.py | snapshot_folder | def snapshot_folder():
"""
Use the commit date in UTC as folder name
"""
logger.info("Snapshot folder")
try:
stdout = subprocess.check_output(["git", "show", "-s", "--format=%cI", "HEAD"])
except subprocess.CalledProcessError as e:
logger.error("Error: {}".format(e.output.decode(... | python | def snapshot_folder():
logger.info("Snapshot folder")
try:
stdout = subprocess.check_output(["git", "show", "-s", "--format=%cI", "HEAD"])
except subprocess.CalledProcessError as e:
logger.error("Error: {}".format(e.output.decode('ascii', 'ignore').strip()))
sys.exit(2)
except Fi... | [
"def",
"snapshot_folder",
"(",
")",
":",
"logger",
".",
"info",
"(",
"\"Snapshot folder\"",
")",
"try",
":",
"stdout",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"git\"",
",",
"\"show\"",
",",
"\"-s\"",
",",
"\"--format=%cI\"",
",",
"\"HEAD\"",
"]",... | Use the commit date in UTC as folder name | [
"Use",
"the",
"commit",
"date",
"in",
"UTC",
"as",
"folder",
"name"
] | d33186e54e436ebb1537e5baf67758e3bd3bf076 | https://github.com/spaam/svtplay-dl/blob/d33186e54e436ebb1537e5baf67758e3bd3bf076/scripts/cibuild.py#L76-L92 |
249,306 | spaam/svtplay-dl | lib/svtplay_dl/service/__init__.py | opengraph_get | def opengraph_get(html, prop):
"""
Extract specified OpenGraph property from html.
>>> opengraph_get('<html><head><meta property="og:image" content="http://example.com/img.jpg"><meta ...', "image")
'http://example.com/img.jpg'
>>> opengraph_get('<html><head><meta content="http://example... | python | def opengraph_get(html, prop):
match = re.search('<meta [^>]*property="og:' + prop + '" content="([^"]*)"', html)
if match is None:
match = re.search('<meta [^>]*content="([^"]*)" property="og:' + prop + '"', html)
if match is None:
return None
return match.group(1) | [
"def",
"opengraph_get",
"(",
"html",
",",
"prop",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"'<meta [^>]*property=\"og:'",
"+",
"prop",
"+",
"'\" content=\"([^\"]*)\"'",
",",
"html",
")",
"if",
"match",
"is",
"None",
":",
"match",
"=",
"re",
".",
... | Extract specified OpenGraph property from html.
>>> opengraph_get('<html><head><meta property="og:image" content="http://example.com/img.jpg"><meta ...', "image")
'http://example.com/img.jpg'
>>> opengraph_get('<html><head><meta content="http://example.com/img2.jpg" property="og:image"><meta ..... | [
"Extract",
"specified",
"OpenGraph",
"property",
"from",
"html",
"."
] | d33186e54e436ebb1537e5baf67758e3bd3bf076 | https://github.com/spaam/svtplay-dl/blob/d33186e54e436ebb1537e5baf67758e3bd3bf076/lib/svtplay_dl/service/__init__.py#L82-L98 |
249,307 | spaam/svtplay-dl | lib/svtplay_dl/utils/text.py | decode_html_entities | def decode_html_entities(s):
"""
Replaces html entities with the character they represent.
>>> print(decode_html_entities("<3 &"))
<3 &
"""
parser = HTMLParser.HTMLParser()
def unesc(m):
return parser.unescape(m.group())
return re.sub(r'(&[^;]+;)', unesc, ensure_... | python | def decode_html_entities(s):
parser = HTMLParser.HTMLParser()
def unesc(m):
return parser.unescape(m.group())
return re.sub(r'(&[^;]+;)', unesc, ensure_unicode(s)) | [
"def",
"decode_html_entities",
"(",
"s",
")",
":",
"parser",
"=",
"HTMLParser",
".",
"HTMLParser",
"(",
")",
"def",
"unesc",
"(",
"m",
")",
":",
"return",
"parser",
".",
"unescape",
"(",
"m",
".",
"group",
"(",
")",
")",
"return",
"re",
".",
"sub",
... | Replaces html entities with the character they represent.
>>> print(decode_html_entities("<3 &"))
<3 & | [
"Replaces",
"html",
"entities",
"with",
"the",
"character",
"they",
"represent",
"."
] | d33186e54e436ebb1537e5baf67758e3bd3bf076 | https://github.com/spaam/svtplay-dl/blob/d33186e54e436ebb1537e5baf67758e3bd3bf076/lib/svtplay_dl/utils/text.py#L17-L28 |
249,308 | spaam/svtplay-dl | lib/svtplay_dl/utils/text.py | filenamify | def filenamify(title):
"""
Convert a string to something suitable as a file name. E.g.
Matlagning del 1 av 10 - Räksmörgås | SVT Play
-> matlagning.del.1.av.10.-.raksmorgas.svt.play
"""
# ensure it is unicode
title = ensure_unicode(title)
# NFD decomposes chars into base char and ... | python | def filenamify(title):
# ensure it is unicode
title = ensure_unicode(title)
# NFD decomposes chars into base char and diacritical mark, which
# means that we will get base char when we strip out non-ascii.
title = unicodedata.normalize('NFD', title)
# Convert to lowercase
# Drop any non as... | [
"def",
"filenamify",
"(",
"title",
")",
":",
"# ensure it is unicode",
"title",
"=",
"ensure_unicode",
"(",
"title",
")",
"# NFD decomposes chars into base char and diacritical mark, which",
"# means that we will get base char when we strip out non-ascii.",
"title",
"=",
"unicodeda... | Convert a string to something suitable as a file name. E.g.
Matlagning del 1 av 10 - Räksmörgås | SVT Play
-> matlagning.del.1.av.10.-.raksmorgas.svt.play | [
"Convert",
"a",
"string",
"to",
"something",
"suitable",
"as",
"a",
"file",
"name",
".",
"E",
".",
"g",
"."
] | d33186e54e436ebb1537e5baf67758e3bd3bf076 | https://github.com/spaam/svtplay-dl/blob/d33186e54e436ebb1537e5baf67758e3bd3bf076/lib/svtplay_dl/utils/text.py#L31-L54 |
249,309 | spaam/svtplay-dl | lib/svtplay_dl/fetcher/http.py | HTTP.download | def download(self):
""" Get the stream from HTTP """
_, ext = os.path.splitext(self.url)
if ext == ".mp3":
self.output_extention = "mp3"
else:
self.output_extention = "mp4" # this might be wrong..
data = self.http.request("get", self.url, stream=True)
... | python | def download(self):
_, ext = os.path.splitext(self.url)
if ext == ".mp3":
self.output_extention = "mp3"
else:
self.output_extention = "mp4" # this might be wrong..
data = self.http.request("get", self.url, stream=True)
try:
total_size = data.h... | [
"def",
"download",
"(",
"self",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"self",
".",
"url",
")",
"if",
"ext",
"==",
"\".mp3\"",
":",
"self",
".",
"output_extention",
"=",
"\"mp3\"",
"else",
":",
"self",
".",
"output... | Get the stream from HTTP | [
"Get",
"the",
"stream",
"from",
"HTTP"
] | d33186e54e436ebb1537e5baf67758e3bd3bf076 | https://github.com/spaam/svtplay-dl/blob/d33186e54e436ebb1537e5baf67758e3bd3bf076/lib/svtplay_dl/fetcher/http.py#L15-L43 |
249,310 | spaam/svtplay-dl | lib/svtplay_dl/utils/output.py | progress | def progress(byte, total, extra=""):
""" Print some info about how much we have downloaded """
if total == 0:
progresstr = "Downloaded %dkB bytes" % (byte >> 10)
progress_stream.write(progresstr + '\r')
return
progressbar(total, byte, extra) | python | def progress(byte, total, extra=""):
if total == 0:
progresstr = "Downloaded %dkB bytes" % (byte >> 10)
progress_stream.write(progresstr + '\r')
return
progressbar(total, byte, extra) | [
"def",
"progress",
"(",
"byte",
",",
"total",
",",
"extra",
"=",
"\"\"",
")",
":",
"if",
"total",
"==",
"0",
":",
"progresstr",
"=",
"\"Downloaded %dkB bytes\"",
"%",
"(",
"byte",
">>",
"10",
")",
"progress_stream",
".",
"write",
"(",
"progresstr",
"+",
... | Print some info about how much we have downloaded | [
"Print",
"some",
"info",
"about",
"how",
"much",
"we",
"have",
"downloaded"
] | d33186e54e436ebb1537e5baf67758e3bd3bf076 | https://github.com/spaam/svtplay-dl/blob/d33186e54e436ebb1537e5baf67758e3bd3bf076/lib/svtplay_dl/utils/output.py#L80-L86 |
249,311 | spaam/svtplay-dl | lib/svtplay_dl/utils/output.py | ETA.update | def update(self, pos):
"""
Set new absolute progress position.
Parameters:
pos: new absolute progress
"""
self.pos = pos
self.now = time.time() | python | def update(self, pos):
self.pos = pos
self.now = time.time() | [
"def",
"update",
"(",
"self",
",",
"pos",
")",
":",
"self",
".",
"pos",
"=",
"pos",
"self",
".",
"now",
"=",
"time",
".",
"time",
"(",
")"
] | Set new absolute progress position.
Parameters:
pos: new absolute progress | [
"Set",
"new",
"absolute",
"progress",
"position",
"."
] | d33186e54e436ebb1537e5baf67758e3bd3bf076 | https://github.com/spaam/svtplay-dl/blob/d33186e54e436ebb1537e5baf67758e3bd3bf076/lib/svtplay_dl/utils/output.py#L39-L47 |
249,312 | ArduPilot/MAVProxy | MAVProxy/modules/lib/graph_ui.py | Graph_UI.check_xlim_change | def check_xlim_change(self):
'''check for new X bounds'''
if self.xlim_pipe is None:
return None
xlim = None
while self.xlim_pipe[0].poll():
try:
xlim = self.xlim_pipe[0].recv()
except EOFError:
return None
if xl... | python | def check_xlim_change(self):
'''check for new X bounds'''
if self.xlim_pipe is None:
return None
xlim = None
while self.xlim_pipe[0].poll():
try:
xlim = self.xlim_pipe[0].recv()
except EOFError:
return None
if xl... | [
"def",
"check_xlim_change",
"(",
"self",
")",
":",
"if",
"self",
".",
"xlim_pipe",
"is",
"None",
":",
"return",
"None",
"xlim",
"=",
"None",
"while",
"self",
".",
"xlim_pipe",
"[",
"0",
"]",
".",
"poll",
"(",
")",
":",
"try",
":",
"xlim",
"=",
"sel... | check for new X bounds | [
"check",
"for",
"new",
"X",
"bounds"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/graph_ui.py#L50-L62 |
249,313 | ArduPilot/MAVProxy | MAVProxy/modules/lib/graph_ui.py | Graph_UI.set_xlim | def set_xlim(self, xlim):
'''set new X bounds'''
if self.xlim_pipe is not None and self.xlim != xlim:
#print("send0: ", graph_count, xlim)
try:
self.xlim_pipe[0].send(xlim)
except IOError:
return False
self.xlim = xlim
... | python | def set_xlim(self, xlim):
'''set new X bounds'''
if self.xlim_pipe is not None and self.xlim != xlim:
#print("send0: ", graph_count, xlim)
try:
self.xlim_pipe[0].send(xlim)
except IOError:
return False
self.xlim = xlim
... | [
"def",
"set_xlim",
"(",
"self",
",",
"xlim",
")",
":",
"if",
"self",
".",
"xlim_pipe",
"is",
"not",
"None",
"and",
"self",
".",
"xlim",
"!=",
"xlim",
":",
"#print(\"send0: \", graph_count, xlim)",
"try",
":",
"self",
".",
"xlim_pipe",
"[",
"0",
"]",
".",... | set new X bounds | [
"set",
"new",
"X",
"bounds"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/graph_ui.py#L64-L73 |
249,314 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_serial.py | SerialModule.serial_lock | def serial_lock(self, lock):
'''lock or unlock the port'''
mav = self.master.mav
if lock:
flags = mavutil.mavlink.SERIAL_CONTROL_FLAG_EXCLUSIVE
self.locked = True
else:
flags = 0
self.locked = False
mav.serial_control_send(self.seri... | python | def serial_lock(self, lock):
'''lock or unlock the port'''
mav = self.master.mav
if lock:
flags = mavutil.mavlink.SERIAL_CONTROL_FLAG_EXCLUSIVE
self.locked = True
else:
flags = 0
self.locked = False
mav.serial_control_send(self.seri... | [
"def",
"serial_lock",
"(",
"self",
",",
"lock",
")",
":",
"mav",
"=",
"self",
".",
"master",
".",
"mav",
"if",
"lock",
":",
"flags",
"=",
"mavutil",
".",
"mavlink",
".",
"SERIAL_CONTROL_FLAG_EXCLUSIVE",
"self",
".",
"locked",
"=",
"True",
"else",
":",
... | lock or unlock the port | [
"lock",
"or",
"unlock",
"the",
"port"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_serial.py#L32-L43 |
249,315 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_serial.py | SerialModule.cmd_serial | def cmd_serial(self, args):
'''serial control commands'''
usage = "Usage: serial <lock|unlock|set|send>"
if len(args) < 1:
print(usage)
return
if args[0] == "lock":
self.serial_lock(True)
elif args[0] == "unlock":
self.serial_lock(F... | python | def cmd_serial(self, args):
'''serial control commands'''
usage = "Usage: serial <lock|unlock|set|send>"
if len(args) < 1:
print(usage)
return
if args[0] == "lock":
self.serial_lock(True)
elif args[0] == "unlock":
self.serial_lock(F... | [
"def",
"cmd_serial",
"(",
"self",
",",
"args",
")",
":",
"usage",
"=",
"\"Usage: serial <lock|unlock|set|send>\"",
"if",
"len",
"(",
"args",
")",
"<",
"1",
":",
"print",
"(",
"usage",
")",
"return",
"if",
"args",
"[",
"0",
"]",
"==",
"\"lock\"",
":",
"... | serial control commands | [
"serial",
"control",
"commands"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_serial.py#L67-L82 |
249,316 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/mp_tile.py | MPTile.downloader | def downloader(self):
'''the download thread'''
while self.tiles_pending() > 0:
time.sleep(self.tile_delay)
keys = sorted(self._download_pending.keys())
# work out which one to download next, choosing by request_time
tile_info = self._download_pending[ke... | python | def downloader(self):
'''the download thread'''
while self.tiles_pending() > 0:
time.sleep(self.tile_delay)
keys = sorted(self._download_pending.keys())
# work out which one to download next, choosing by request_time
tile_info = self._download_pending[ke... | [
"def",
"downloader",
"(",
"self",
")",
":",
"while",
"self",
".",
"tiles_pending",
"(",
")",
">",
"0",
":",
"time",
".",
"sleep",
"(",
"self",
".",
"tile_delay",
")",
"keys",
"=",
"sorted",
"(",
"self",
".",
"_download_pending",
".",
"keys",
"(",
")"... | the download thread | [
"the",
"download",
"thread"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_tile.py#L250-L313 |
249,317 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.cmd_fw | def cmd_fw(self, args):
'''execute command defined in args'''
if len(args) == 0:
print(self.usage())
return
rest = args[1:]
if args[0] == "manifest":
self.cmd_fw_manifest(rest)
elif args[0] == "list":
self.cmd_fw_list(rest)
... | python | def cmd_fw(self, args):
'''execute command defined in args'''
if len(args) == 0:
print(self.usage())
return
rest = args[1:]
if args[0] == "manifest":
self.cmd_fw_manifest(rest)
elif args[0] == "list":
self.cmd_fw_list(rest)
... | [
"def",
"cmd_fw",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"print",
"(",
"self",
".",
"usage",
"(",
")",
")",
"return",
"rest",
"=",
"args",
"[",
"1",
":",
"]",
"if",
"args",
"[",
"0",
"]",
"==",
"\"... | execute command defined in args | [
"execute",
"command",
"defined",
"in",
"args"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L47-L62 |
249,318 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.frame_from_firmware | def frame_from_firmware(self, firmware):
'''extract information from firmware, return pretty string to user'''
# see Tools/scripts/generate-manifest for this map:
frame_to_mavlink_dict = {
"quad": "QUADROTOR",
"hexa": "HEXAROTOR",
"y6": "ARDUPILOT_Y6",
... | python | def frame_from_firmware(self, firmware):
'''extract information from firmware, return pretty string to user'''
# see Tools/scripts/generate-manifest for this map:
frame_to_mavlink_dict = {
"quad": "QUADROTOR",
"hexa": "HEXAROTOR",
"y6": "ARDUPILOT_Y6",
... | [
"def",
"frame_from_firmware",
"(",
"self",
",",
"firmware",
")",
":",
"# see Tools/scripts/generate-manifest for this map:",
"frame_to_mavlink_dict",
"=",
"{",
"\"quad\"",
":",
"\"QUADROTOR\"",
",",
"\"hexa\"",
":",
"\"HEXAROTOR\"",
",",
"\"y6\"",
":",
"\"ARDUPILOT_Y6\"",... | extract information from firmware, return pretty string to user | [
"extract",
"information",
"from",
"firmware",
"return",
"pretty",
"string",
"to",
"user"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L64-L87 |
249,319 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.row_is_filtered | def row_is_filtered(self, row_subs, filters):
'''returns True if row should NOT be included according to filters'''
for filtername in filters:
filtervalue = filters[filtername]
if filtername in row_subs:
row_subs_value = row_subs[filtername]
if str... | python | def row_is_filtered(self, row_subs, filters):
'''returns True if row should NOT be included according to filters'''
for filtername in filters:
filtervalue = filters[filtername]
if filtername in row_subs:
row_subs_value = row_subs[filtername]
if str... | [
"def",
"row_is_filtered",
"(",
"self",
",",
"row_subs",
",",
"filters",
")",
":",
"for",
"filtername",
"in",
"filters",
":",
"filtervalue",
"=",
"filters",
"[",
"filtername",
"]",
"if",
"filtername",
"in",
"row_subs",
":",
"row_subs_value",
"=",
"row_subs",
... | returns True if row should NOT be included according to filters | [
"returns",
"True",
"if",
"row",
"should",
"NOT",
"be",
"included",
"according",
"to",
"filters"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L98-L108 |
249,320 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.filters_from_args | def filters_from_args(self, args):
'''take any argument of the form name=value anmd put it into a dict; return that and the remaining arguments'''
filters = dict()
remainder = []
for arg in args:
try:
equals = arg.index('=')
# anything ofthe fo... | python | def filters_from_args(self, args):
'''take any argument of the form name=value anmd put it into a dict; return that and the remaining arguments'''
filters = dict()
remainder = []
for arg in args:
try:
equals = arg.index('=')
# anything ofthe fo... | [
"def",
"filters_from_args",
"(",
"self",
",",
"args",
")",
":",
"filters",
"=",
"dict",
"(",
")",
"remainder",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"try",
":",
"equals",
"=",
"arg",
".",
"index",
"(",
"'='",
")",
"# anything ofthe form key-v... | take any argument of the form name=value anmd put it into a dict; return that and the remaining arguments | [
"take",
"any",
"argument",
"of",
"the",
"form",
"name",
"=",
"value",
"anmd",
"put",
"it",
"into",
"a",
"dict",
";",
"return",
"that",
"and",
"the",
"remaining",
"arguments"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L110-L121 |
249,321 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.all_firmwares | def all_firmwares(self):
''' return firmware entries from all manifests'''
all = []
for manifest in self.manifests:
for firmware in manifest["firmware"]:
all.append(firmware)
return all | python | def all_firmwares(self):
''' return firmware entries from all manifests'''
all = []
for manifest in self.manifests:
for firmware in manifest["firmware"]:
all.append(firmware)
return all | [
"def",
"all_firmwares",
"(",
"self",
")",
":",
"all",
"=",
"[",
"]",
"for",
"manifest",
"in",
"self",
".",
"manifests",
":",
"for",
"firmware",
"in",
"manifest",
"[",
"\"firmware\"",
"]",
":",
"all",
".",
"append",
"(",
"firmware",
")",
"return",
"all"... | return firmware entries from all manifests | [
"return",
"firmware",
"entries",
"from",
"all",
"manifests"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L123-L129 |
249,322 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.rows_for_firmwares | def rows_for_firmwares(self, firmwares):
'''provide user-readable text for a firmware entry'''
rows = []
i = 0
for firmware in firmwares:
frame = self.frame_from_firmware(firmware)
row = {
"seq": i,
"platform": firmware["platform"],... | python | def rows_for_firmwares(self, firmwares):
'''provide user-readable text for a firmware entry'''
rows = []
i = 0
for firmware in firmwares:
frame = self.frame_from_firmware(firmware)
row = {
"seq": i,
"platform": firmware["platform"],... | [
"def",
"rows_for_firmwares",
"(",
"self",
",",
"firmwares",
")",
":",
"rows",
"=",
"[",
"]",
"i",
"=",
"0",
"for",
"firmware",
"in",
"firmwares",
":",
"frame",
"=",
"self",
".",
"frame_from_firmware",
"(",
"firmware",
")",
"row",
"=",
"{",
"\"seq\"",
"... | provide user-readable text for a firmware entry | [
"provide",
"user",
"-",
"readable",
"text",
"for",
"a",
"firmware",
"entry"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L131-L163 |
249,323 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.filter_rows | def filter_rows(self, filters, rows):
'''returns rows as filtered by filters'''
ret = []
for row in rows:
if not self.row_is_filtered(row, filters):
ret.append(row)
return ret | python | def filter_rows(self, filters, rows):
'''returns rows as filtered by filters'''
ret = []
for row in rows:
if not self.row_is_filtered(row, filters):
ret.append(row)
return ret | [
"def",
"filter_rows",
"(",
"self",
",",
"filters",
",",
"rows",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"row",
"in",
"rows",
":",
"if",
"not",
"self",
".",
"row_is_filtered",
"(",
"row",
",",
"filters",
")",
":",
"ret",
".",
"append",
"(",
"row",
... | returns rows as filtered by filters | [
"returns",
"rows",
"as",
"filtered",
"by",
"filters"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L165-L171 |
249,324 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.filtered_rows_from_args | def filtered_rows_from_args(self, args):
'''extracts filters from args, rows from manifests, returns filtered rows'''
if len(self.manifests) == 0:
print("fw: No manifests downloaded. Try 'manifest download'")
return None
(filters,remainder) = self.filters_from_args(args... | python | def filtered_rows_from_args(self, args):
'''extracts filters from args, rows from manifests, returns filtered rows'''
if len(self.manifests) == 0:
print("fw: No manifests downloaded. Try 'manifest download'")
return None
(filters,remainder) = self.filters_from_args(args... | [
"def",
"filtered_rows_from_args",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"self",
".",
"manifests",
")",
"==",
"0",
":",
"print",
"(",
"\"fw: No manifests downloaded. Try 'manifest download'\"",
")",
"return",
"None",
"(",
"filters",
",",
"remaind... | extracts filters from args, rows from manifests, returns filtered rows | [
"extracts",
"filters",
"from",
"args",
"rows",
"from",
"manifests",
"returns",
"filtered",
"rows"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L173-L183 |
249,325 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.cmd_fw_list | def cmd_fw_list(self, args):
'''cmd handler for list'''
stuff = self.filtered_rows_from_args(args)
if stuff is None:
return
(filtered, remainder) = stuff
print("")
print(" seq platform frame major.minor.patch releasetype latest git-sha format")
for ... | python | def cmd_fw_list(self, args):
'''cmd handler for list'''
stuff = self.filtered_rows_from_args(args)
if stuff is None:
return
(filtered, remainder) = stuff
print("")
print(" seq platform frame major.minor.patch releasetype latest git-sha format")
for ... | [
"def",
"cmd_fw_list",
"(",
"self",
",",
"args",
")",
":",
"stuff",
"=",
"self",
".",
"filtered_rows_from_args",
"(",
"args",
")",
"if",
"stuff",
"is",
"None",
":",
"return",
"(",
"filtered",
",",
"remainder",
")",
"=",
"stuff",
"print",
"(",
"\"\"",
")... | cmd handler for list | [
"cmd",
"handler",
"for",
"list"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L185-L194 |
249,326 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.cmd_fw_download | def cmd_fw_download(self, args):
'''cmd handler for downloading firmware'''
stuff = self.filtered_rows_from_args(args)
if stuff is None:
return
(filtered, remainder) = stuff
if len(filtered) == 0:
print("fw: No firmware specified")
return
... | python | def cmd_fw_download(self, args):
'''cmd handler for downloading firmware'''
stuff = self.filtered_rows_from_args(args)
if stuff is None:
return
(filtered, remainder) = stuff
if len(filtered) == 0:
print("fw: No firmware specified")
return
... | [
"def",
"cmd_fw_download",
"(",
"self",
",",
"args",
")",
":",
"stuff",
"=",
"self",
".",
"filtered_rows_from_args",
"(",
"args",
")",
"if",
"stuff",
"is",
"None",
":",
"return",
"(",
"filtered",
",",
"remainder",
")",
"=",
"stuff",
"if",
"len",
"(",
"f... | cmd handler for downloading firmware | [
"cmd",
"handler",
"for",
"downloading",
"firmware"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L196-L221 |
249,327 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.find_manifests | def find_manifests(self):
'''locate manifests and return filepaths thereof'''
manifest_dir = mp_util.dot_mavproxy()
ret = []
for file in os.listdir(manifest_dir):
try:
file.index("manifest")
ret.append(os.path.join(manifest_dir,file))
... | python | def find_manifests(self):
'''locate manifests and return filepaths thereof'''
manifest_dir = mp_util.dot_mavproxy()
ret = []
for file in os.listdir(manifest_dir):
try:
file.index("manifest")
ret.append(os.path.join(manifest_dir,file))
... | [
"def",
"find_manifests",
"(",
"self",
")",
":",
"manifest_dir",
"=",
"mp_util",
".",
"dot_mavproxy",
"(",
")",
"ret",
"=",
"[",
"]",
"for",
"file",
"in",
"os",
".",
"listdir",
"(",
"manifest_dir",
")",
":",
"try",
":",
"file",
".",
"index",
"(",
"\"m... | locate manifests and return filepaths thereof | [
"locate",
"manifests",
"and",
"return",
"filepaths",
"thereof"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L231-L242 |
249,328 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.cmd_fw_manifest_purge | def cmd_fw_manifest_purge(self):
'''remove all downloaded manifests'''
for filepath in self.find_manifests():
os.unlink(filepath)
self.manifests_parse() | python | def cmd_fw_manifest_purge(self):
'''remove all downloaded manifests'''
for filepath in self.find_manifests():
os.unlink(filepath)
self.manifests_parse() | [
"def",
"cmd_fw_manifest_purge",
"(",
"self",
")",
":",
"for",
"filepath",
"in",
"self",
".",
"find_manifests",
"(",
")",
":",
"os",
".",
"unlink",
"(",
"filepath",
")",
"self",
".",
"manifests_parse",
"(",
")"
] | remove all downloaded manifests | [
"remove",
"all",
"downloaded",
"manifests"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L253-L257 |
249,329 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.cmd_fw_manifest | def cmd_fw_manifest(self, args):
'''cmd handler for manipulating manifests'''
if len(args) == 0:
print(self.fw_manifest_usage())
return
rest = args[1:]
if args[0] == "download":
return self.manifest_download()
if args[0] == "list":
... | python | def cmd_fw_manifest(self, args):
'''cmd handler for manipulating manifests'''
if len(args) == 0:
print(self.fw_manifest_usage())
return
rest = args[1:]
if args[0] == "download":
return self.manifest_download()
if args[0] == "list":
... | [
"def",
"cmd_fw_manifest",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"print",
"(",
"self",
".",
"fw_manifest_usage",
"(",
")",
")",
"return",
"rest",
"=",
"args",
"[",
"1",
":",
"]",
"if",
"args",
"[",
"0",... | cmd handler for manipulating manifests | [
"cmd",
"handler",
"for",
"manipulating",
"manifests"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L259-L277 |
249,330 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.manifest_parse | def manifest_parse(self, path):
'''parse manifest at path, return JSON object'''
print("fw: parsing manifests")
content = open(path).read()
return json.loads(content) | python | def manifest_parse(self, path):
'''parse manifest at path, return JSON object'''
print("fw: parsing manifests")
content = open(path).read()
return json.loads(content) | [
"def",
"manifest_parse",
"(",
"self",
",",
"path",
")",
":",
"print",
"(",
"\"fw: parsing manifests\"",
")",
"content",
"=",
"open",
"(",
"path",
")",
".",
"read",
"(",
")",
"return",
"json",
".",
"loads",
"(",
"content",
")"
] | parse manifest at path, return JSON object | [
"parse",
"manifest",
"at",
"path",
"return",
"JSON",
"object"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L279-L283 |
249,331 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.manifest_path_is_old | def manifest_path_is_old(self, path):
'''return true if path is more than a day old'''
mtime = os.path.getmtime(path)
return (time.time() - mtime) > 24*60*60 | python | def manifest_path_is_old(self, path):
'''return true if path is more than a day old'''
mtime = os.path.getmtime(path)
return (time.time() - mtime) > 24*60*60 | [
"def",
"manifest_path_is_old",
"(",
"self",
",",
"path",
")",
":",
"mtime",
"=",
"os",
".",
"path",
".",
"getmtime",
"(",
"path",
")",
"return",
"(",
"time",
".",
"time",
"(",
")",
"-",
"mtime",
")",
">",
"24",
"*",
"60",
"*",
"60"
] | return true if path is more than a day old | [
"return",
"true",
"if",
"path",
"is",
"more",
"than",
"a",
"day",
"old"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L289-L292 |
249,332 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.manifests_parse | def manifests_parse(self):
'''parse manifests present on system'''
self.manifests = []
for manifest_path in self.find_manifests():
if self.manifest_path_is_old(manifest_path):
print("fw: Manifest (%s) is old; consider 'manifest download'" % (manifest_path))
... | python | def manifests_parse(self):
'''parse manifests present on system'''
self.manifests = []
for manifest_path in self.find_manifests():
if self.manifest_path_is_old(manifest_path):
print("fw: Manifest (%s) is old; consider 'manifest download'" % (manifest_path))
... | [
"def",
"manifests_parse",
"(",
"self",
")",
":",
"self",
".",
"manifests",
"=",
"[",
"]",
"for",
"manifest_path",
"in",
"self",
".",
"find_manifests",
"(",
")",
":",
"if",
"self",
".",
"manifest_path_is_old",
"(",
"manifest_path",
")",
":",
"print",
"(",
... | parse manifests present on system | [
"parse",
"manifests",
"present",
"on",
"system"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L294-L304 |
249,333 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.make_safe_filename_from_url | def make_safe_filename_from_url(self, url):
'''return a version of url safe for use as a filename'''
r = re.compile("([^a-zA-Z0-9_.-])")
filename = r.sub(lambda m : "%" + str(hex(ord(str(m.group(1))))).upper(), url)
return filename | python | def make_safe_filename_from_url(self, url):
'''return a version of url safe for use as a filename'''
r = re.compile("([^a-zA-Z0-9_.-])")
filename = r.sub(lambda m : "%" + str(hex(ord(str(m.group(1))))).upper(), url)
return filename | [
"def",
"make_safe_filename_from_url",
"(",
"self",
",",
"url",
")",
":",
"r",
"=",
"re",
".",
"compile",
"(",
"\"([^a-zA-Z0-9_.-])\"",
")",
"filename",
"=",
"r",
".",
"sub",
"(",
"lambda",
"m",
":",
"\"%\"",
"+",
"str",
"(",
"hex",
"(",
"ord",
"(",
"... | return a version of url safe for use as a filename | [
"return",
"a",
"version",
"of",
"url",
"safe",
"for",
"use",
"as",
"a",
"filename"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L324-L328 |
249,334 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_firmware.py | FirmwareModule.manifest_download | def manifest_download(self):
'''download manifest files'''
if self.downloaders_lock.acquire(False):
if len(self.downloaders):
# there already exist downloader threads
self.downloaders_lock.release()
return
for url in ['http://firmw... | python | def manifest_download(self):
'''download manifest files'''
if self.downloaders_lock.acquire(False):
if len(self.downloaders):
# there already exist downloader threads
self.downloaders_lock.release()
return
for url in ['http://firmw... | [
"def",
"manifest_download",
"(",
"self",
")",
":",
"if",
"self",
".",
"downloaders_lock",
".",
"acquire",
"(",
"False",
")",
":",
"if",
"len",
"(",
"self",
".",
"downloaders",
")",
":",
"# there already exist downloader threads",
"self",
".",
"downloaders_lock",... | download manifest files | [
"download",
"manifest",
"files"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_firmware.py#L330-L345 |
249,335 | ArduPilot/MAVProxy | MAVProxy/tools/mavflightview.py | colour_for_point | def colour_for_point(mlog, point, instance, options):
global colour_expression_exceptions, colour_source_max, colour_source_min
'''indicate a colour to be used to plot point'''
source = getattr(options, "colour_source", "flightmode")
if source == "flightmode":
return colour_for_point_flightmode(... | python | def colour_for_point(mlog, point, instance, options):
global colour_expression_exceptions, colour_source_max, colour_source_min
'''indicate a colour to be used to plot point'''
source = getattr(options, "colour_source", "flightmode")
if source == "flightmode":
return colour_for_point_flightmode(... | [
"def",
"colour_for_point",
"(",
"mlog",
",",
"point",
",",
"instance",
",",
"options",
")",
":",
"global",
"colour_expression_exceptions",
",",
"colour_source_max",
",",
"colour_source_min",
"source",
"=",
"getattr",
"(",
"options",
",",
"\"colour_source\"",
",",
... | indicate a colour to be used to plot point | [
"indicate",
"a",
"colour",
"to",
"be",
"used",
"to",
"plot",
"point"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/tools/mavflightview.py#L154-L201 |
249,336 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_restserver.py | mavlink_to_json | def mavlink_to_json(msg):
'''Translate mavlink python messages in json string'''
ret = '\"%s\": {' % msg._type
for fieldname in msg._fieldnames:
data = getattr(msg, fieldname)
ret += '\"%s\" : \"%s\", ' % (fieldname, data)
ret = ret[0:-2] + '}'
return ret | python | def mavlink_to_json(msg):
'''Translate mavlink python messages in json string'''
ret = '\"%s\": {' % msg._type
for fieldname in msg._fieldnames:
data = getattr(msg, fieldname)
ret += '\"%s\" : \"%s\", ' % (fieldname, data)
ret = ret[0:-2] + '}'
return ret | [
"def",
"mavlink_to_json",
"(",
"msg",
")",
":",
"ret",
"=",
"'\\\"%s\\\": {'",
"%",
"msg",
".",
"_type",
"for",
"fieldname",
"in",
"msg",
".",
"_fieldnames",
":",
"data",
"=",
"getattr",
"(",
"msg",
",",
"fieldname",
")",
"ret",
"+=",
"'\\\"%s\\\" : \\\"%s... | Translate mavlink python messages in json string | [
"Translate",
"mavlink",
"python",
"messages",
"in",
"json",
"string"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_restserver.py#L18-L25 |
249,337 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_restserver.py | mpstatus_to_json | def mpstatus_to_json(status):
'''Translate MPStatus in json string'''
msg_keys = list(status.msgs.keys())
data = '{'
for key in msg_keys[:-1]:
data += mavlink_to_json(status.msgs[key]) + ','
data += mavlink_to_json(status.msgs[msg_keys[-1]])
data += '}'
return data | python | def mpstatus_to_json(status):
'''Translate MPStatus in json string'''
msg_keys = list(status.msgs.keys())
data = '{'
for key in msg_keys[:-1]:
data += mavlink_to_json(status.msgs[key]) + ','
data += mavlink_to_json(status.msgs[msg_keys[-1]])
data += '}'
return data | [
"def",
"mpstatus_to_json",
"(",
"status",
")",
":",
"msg_keys",
"=",
"list",
"(",
"status",
".",
"msgs",
".",
"keys",
"(",
")",
")",
"data",
"=",
"'{'",
"for",
"key",
"in",
"msg_keys",
"[",
":",
"-",
"1",
"]",
":",
"data",
"+=",
"mavlink_to_json",
... | Translate MPStatus in json string | [
"Translate",
"MPStatus",
"in",
"json",
"string"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_restserver.py#L27-L35 |
249,338 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_restserver.py | RestServer.set_ip_port | def set_ip_port(self, ip, port):
'''set ip and port'''
self.address = ip
self.port = port
self.stop()
self.start() | python | def set_ip_port(self, ip, port):
'''set ip and port'''
self.address = ip
self.port = port
self.stop()
self.start() | [
"def",
"set_ip_port",
"(",
"self",
",",
"ip",
",",
"port",
")",
":",
"self",
".",
"address",
"=",
"ip",
"self",
".",
"port",
"=",
"port",
"self",
".",
"stop",
"(",
")",
"self",
".",
"start",
"(",
")"
] | set ip and port | [
"set",
"ip",
"and",
"port"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_restserver.py#L59-L64 |
249,339 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_restserver.py | RestServer.request | def request(self, arg=None):
'''Deal with requests'''
if not self.status:
return '{"result": "No message"}'
try:
status_dict = json.loads(mpstatus_to_json(self.status))
except Exception as e:
print(e)
return
# If no key, send the ... | python | def request(self, arg=None):
'''Deal with requests'''
if not self.status:
return '{"result": "No message"}'
try:
status_dict = json.loads(mpstatus_to_json(self.status))
except Exception as e:
print(e)
return
# If no key, send the ... | [
"def",
"request",
"(",
"self",
",",
"arg",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"status",
":",
"return",
"'{\"result\": \"No message\"}'",
"try",
":",
"status_dict",
"=",
"json",
".",
"loads",
"(",
"mpstatus_to_json",
"(",
"self",
".",
"status"... | Deal with requests | [
"Deal",
"with",
"requests"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_restserver.py#L93-L117 |
249,340 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_battery.py | BatteryModule.power_status_update | def power_status_update(self, POWER_STATUS):
'''update POWER_STATUS warnings level'''
now = time.time()
Vservo = POWER_STATUS.Vservo * 0.001
Vcc = POWER_STATUS.Vcc * 0.001
self.high_servo_voltage = max(self.high_servo_voltage, Vservo)
if self.high_servo_voltage > 1 and Vs... | python | def power_status_update(self, POWER_STATUS):
'''update POWER_STATUS warnings level'''
now = time.time()
Vservo = POWER_STATUS.Vservo * 0.001
Vcc = POWER_STATUS.Vcc * 0.001
self.high_servo_voltage = max(self.high_servo_voltage, Vservo)
if self.high_servo_voltage > 1 and Vs... | [
"def",
"power_status_update",
"(",
"self",
",",
"POWER_STATUS",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"Vservo",
"=",
"POWER_STATUS",
".",
"Vservo",
"*",
"0.001",
"Vcc",
"=",
"POWER_STATUS",
".",
"Vcc",
"*",
"0.001",
"self",
".",
"high_serv... | update POWER_STATUS warnings level | [
"update",
"POWER_STATUS",
"warnings",
"level"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_battery.py#L101-L118 |
249,341 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_gasheli.py | GasHeliModule.valid_starter_settings | def valid_starter_settings(self):
'''check starter settings'''
if self.gasheli_settings.ignition_chan <= 0 or self.gasheli_settings.ignition_chan > 8:
print("Invalid ignition channel %d" % self.gasheli_settings.ignition_chan)
return False
if self.gasheli_settings.starter_... | python | def valid_starter_settings(self):
'''check starter settings'''
if self.gasheli_settings.ignition_chan <= 0 or self.gasheli_settings.ignition_chan > 8:
print("Invalid ignition channel %d" % self.gasheli_settings.ignition_chan)
return False
if self.gasheli_settings.starter_... | [
"def",
"valid_starter_settings",
"(",
"self",
")",
":",
"if",
"self",
".",
"gasheli_settings",
".",
"ignition_chan",
"<=",
"0",
"or",
"self",
".",
"gasheli_settings",
".",
"ignition_chan",
">",
"8",
":",
"print",
"(",
"\"Invalid ignition channel %d\"",
"%",
"sel... | check starter settings | [
"check",
"starter",
"settings"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_gasheli.py#L73-L81 |
249,342 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_gasheli.py | GasHeliModule.cmd_gasheli | def cmd_gasheli(self, args):
'''gas help commands'''
usage = "Usage: gasheli <start|stop|set>"
if len(args) < 1:
print(usage)
return
if args[0] == "start":
self.start_motor()
elif args[0] == "stop":
self.stop_motor()
elif ar... | python | def cmd_gasheli(self, args):
'''gas help commands'''
usage = "Usage: gasheli <start|stop|set>"
if len(args) < 1:
print(usage)
return
if args[0] == "start":
self.start_motor()
elif args[0] == "stop":
self.stop_motor()
elif ar... | [
"def",
"cmd_gasheli",
"(",
"self",
",",
"args",
")",
":",
"usage",
"=",
"\"Usage: gasheli <start|stop|set>\"",
"if",
"len",
"(",
"args",
")",
"<",
"1",
":",
"print",
"(",
"usage",
")",
"return",
"if",
"args",
"[",
"0",
"]",
"==",
"\"start\"",
":",
"sel... | gas help commands | [
"gas",
"help",
"commands"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_gasheli.py#L135-L148 |
249,343 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.wploader | def wploader(self):
'''per-sysid wploader'''
if self.target_system not in self.wploader_by_sysid:
self.wploader_by_sysid[self.target_system] = mavwp.MAVWPLoader()
return self.wploader_by_sysid[self.target_system] | python | def wploader(self):
'''per-sysid wploader'''
if self.target_system not in self.wploader_by_sysid:
self.wploader_by_sysid[self.target_system] = mavwp.MAVWPLoader()
return self.wploader_by_sysid[self.target_system] | [
"def",
"wploader",
"(",
"self",
")",
":",
"if",
"self",
".",
"target_system",
"not",
"in",
"self",
".",
"wploader_by_sysid",
":",
"self",
".",
"wploader_by_sysid",
"[",
"self",
".",
"target_system",
"]",
"=",
"mavwp",
".",
"MAVWPLoader",
"(",
")",
"return"... | per-sysid wploader | [
"per",
"-",
"sysid",
"wploader"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L60-L64 |
249,344 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.send_wp_requests | def send_wp_requests(self, wps=None):
'''send some more WP requests'''
if wps is None:
wps = self.missing_wps_to_request()
tnow = time.time()
for seq in wps:
#print("REQUESTING %u/%u (%u)" % (seq, self.wploader.expected_count, i))
self.wp_requested[seq... | python | def send_wp_requests(self, wps=None):
'''send some more WP requests'''
if wps is None:
wps = self.missing_wps_to_request()
tnow = time.time()
for seq in wps:
#print("REQUESTING %u/%u (%u)" % (seq, self.wploader.expected_count, i))
self.wp_requested[seq... | [
"def",
"send_wp_requests",
"(",
"self",
",",
"wps",
"=",
"None",
")",
":",
"if",
"wps",
"is",
"None",
":",
"wps",
"=",
"self",
".",
"missing_wps_to_request",
"(",
")",
"tnow",
"=",
"time",
".",
"time",
"(",
")",
"for",
"seq",
"in",
"wps",
":",
"#pr... | send some more WP requests | [
"send",
"some",
"more",
"WP",
"requests"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L79-L87 |
249,345 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.wp_status | def wp_status(self):
'''show status of wp download'''
try:
print("Have %u of %u waypoints" % (self.wploader.count()+len(self.wp_received), self.wploader.expected_count))
except Exception:
print("Have %u waypoints" % (self.wploader.count()+len(self.wp_received))) | python | def wp_status(self):
'''show status of wp download'''
try:
print("Have %u of %u waypoints" % (self.wploader.count()+len(self.wp_received), self.wploader.expected_count))
except Exception:
print("Have %u waypoints" % (self.wploader.count()+len(self.wp_received))) | [
"def",
"wp_status",
"(",
"self",
")",
":",
"try",
":",
"print",
"(",
"\"Have %u of %u waypoints\"",
"%",
"(",
"self",
".",
"wploader",
".",
"count",
"(",
")",
"+",
"len",
"(",
"self",
".",
"wp_received",
")",
",",
"self",
".",
"wploader",
".",
"expecte... | show status of wp download | [
"show",
"status",
"of",
"wp",
"download"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L89-L94 |
249,346 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.wp_slope | def wp_slope(self):
'''show slope of waypoints'''
last_w = None
for i in range(1, self.wploader.count()):
w = self.wploader.wp(i)
if w.command not in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, mavutil.mavlink.MAV_CMD_NAV_LAND]:
continue
if last_w i... | python | def wp_slope(self):
'''show slope of waypoints'''
last_w = None
for i in range(1, self.wploader.count()):
w = self.wploader.wp(i)
if w.command not in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, mavutil.mavlink.MAV_CMD_NAV_LAND]:
continue
if last_w i... | [
"def",
"wp_slope",
"(",
"self",
")",
":",
"last_w",
"=",
"None",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"self",
".",
"wploader",
".",
"count",
"(",
")",
")",
":",
"w",
"=",
"self",
".",
"wploader",
".",
"wp",
"(",
"i",
")",
"if",
"w",
".",... | show slope of waypoints | [
"show",
"slope",
"of",
"waypoints"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L97-L114 |
249,347 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.save_waypoints_csv | def save_waypoints_csv(self, filename):
'''save waypoints to a file in a human readable CSV file'''
try:
#need to remove the leading and trailing quotes in filename
self.wploader.savecsv(filename.strip('"'))
except Exception as msg:
print("Failed to save %s - ... | python | def save_waypoints_csv(self, filename):
'''save waypoints to a file in a human readable CSV file'''
try:
#need to remove the leading and trailing quotes in filename
self.wploader.savecsv(filename.strip('"'))
except Exception as msg:
print("Failed to save %s - ... | [
"def",
"save_waypoints_csv",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"#need to remove the leading and trailing quotes in filename",
"self",
".",
"wploader",
".",
"savecsv",
"(",
"filename",
".",
"strip",
"(",
"'\"'",
")",
")",
"except",
"Exception",
"a... | save waypoints to a file in a human readable CSV file | [
"save",
"waypoints",
"to",
"a",
"file",
"in",
"a",
"human",
"readable",
"CSV",
"file"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L293-L301 |
249,348 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.get_home | def get_home(self):
'''get home location'''
if 'HOME_POSITION' in self.master.messages:
h = self.master.messages['HOME_POSITION']
return mavutil.mavlink.MAVLink_mission_item_message(self.target_system,
self.target_co... | python | def get_home(self):
'''get home location'''
if 'HOME_POSITION' in self.master.messages:
h = self.master.messages['HOME_POSITION']
return mavutil.mavlink.MAVLink_mission_item_message(self.target_system,
self.target_co... | [
"def",
"get_home",
"(",
"self",
")",
":",
"if",
"'HOME_POSITION'",
"in",
"self",
".",
"master",
".",
"messages",
":",
"h",
"=",
"self",
".",
"master",
".",
"messages",
"[",
"'HOME_POSITION'",
"]",
"return",
"mavutil",
".",
"mavlink",
".",
"MAVLink_mission_... | get home location | [
"get",
"home",
"location"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L313-L326 |
249,349 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.nofly_add | def nofly_add(self):
'''add a square flight exclusion zone'''
try:
latlon = self.module('map').click_position
except Exception:
print("No position chosen")
return
loader = self.wploader
(center_lat, center_lon) = latlon
points = []
... | python | def nofly_add(self):
'''add a square flight exclusion zone'''
try:
latlon = self.module('map').click_position
except Exception:
print("No position chosen")
return
loader = self.wploader
(center_lat, center_lon) = latlon
points = []
... | [
"def",
"nofly_add",
"(",
"self",
")",
":",
"try",
":",
"latlon",
"=",
"self",
".",
"module",
"(",
"'map'",
")",
".",
"click_position",
"except",
"Exception",
":",
"print",
"(",
"\"No position chosen\"",
")",
"return",
"loader",
"=",
"self",
".",
"wploader"... | add a square flight exclusion zone | [
"add",
"a",
"square",
"flight",
"exclusion",
"zone"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L368-L392 |
249,350 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.cmd_wp_changealt | def cmd_wp_changealt(self, args):
'''handle wp change target alt of multiple waypoints'''
if len(args) < 2:
print("usage: wp changealt WPNUM NEWALT <NUMWP>")
return
idx = int(args[0])
if idx < 1 or idx > self.wploader.count():
print("Invalid wp number ... | python | def cmd_wp_changealt(self, args):
'''handle wp change target alt of multiple waypoints'''
if len(args) < 2:
print("usage: wp changealt WPNUM NEWALT <NUMWP>")
return
idx = int(args[0])
if idx < 1 or idx > self.wploader.count():
print("Invalid wp number ... | [
"def",
"cmd_wp_changealt",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"2",
":",
"print",
"(",
"\"usage: wp changealt WPNUM NEWALT <NUMWP>\"",
")",
"return",
"idx",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
")",
"if",
"idx",
"... | handle wp change target alt of multiple waypoints | [
"handle",
"wp",
"change",
"target",
"alt",
"of",
"multiple",
"waypoints"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L535-L564 |
249,351 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.cmd_wp_remove | def cmd_wp_remove(self, args):
'''handle wp remove'''
if len(args) != 1:
print("usage: wp remove WPNUM")
return
idx = int(args[0])
if idx < 0 or idx >= self.wploader.count():
print("Invalid wp number %u" % idx)
return
wp = self.wplo... | python | def cmd_wp_remove(self, args):
'''handle wp remove'''
if len(args) != 1:
print("usage: wp remove WPNUM")
return
idx = int(args[0])
if idx < 0 or idx >= self.wploader.count():
print("Invalid wp number %u" % idx)
return
wp = self.wplo... | [
"def",
"cmd_wp_remove",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
":",
"print",
"(",
"\"usage: wp remove WPNUM\"",
")",
"return",
"idx",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
")",
"if",
"idx",
"<",
"0",
"or",
... | handle wp remove | [
"handle",
"wp",
"remove"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L580-L599 |
249,352 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.cmd_wp_undo | def cmd_wp_undo(self):
'''handle wp undo'''
if self.undo_wp_idx == -1 or self.undo_wp is None:
print("No undo information")
return
wp = self.undo_wp
if self.undo_type == 'move':
wp.target_system = self.target_system
wp.target_component =... | python | def cmd_wp_undo(self):
'''handle wp undo'''
if self.undo_wp_idx == -1 or self.undo_wp is None:
print("No undo information")
return
wp = self.undo_wp
if self.undo_type == 'move':
wp.target_system = self.target_system
wp.target_component =... | [
"def",
"cmd_wp_undo",
"(",
"self",
")",
":",
"if",
"self",
".",
"undo_wp_idx",
"==",
"-",
"1",
"or",
"self",
".",
"undo_wp",
"is",
"None",
":",
"print",
"(",
"\"No undo information\"",
")",
"return",
"wp",
"=",
"self",
".",
"undo_wp",
"if",
"self",
"."... | handle wp undo | [
"handle",
"wp",
"undo"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L601-L625 |
249,353 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.csv_line | def csv_line(self, line):
'''turn a list of values into a CSV line'''
self.csv_sep = ","
return self.csv_sep.join(['"' + str(x) + '"' for x in line]) | python | def csv_line(self, line):
'''turn a list of values into a CSV line'''
self.csv_sep = ","
return self.csv_sep.join(['"' + str(x) + '"' for x in line]) | [
"def",
"csv_line",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"csv_sep",
"=",
"\",\"",
"return",
"self",
".",
"csv_sep",
".",
"join",
"(",
"[",
"'\"'",
"+",
"str",
"(",
"x",
")",
"+",
"'\"'",
"for",
"x",
"in",
"line",
"]",
")"
] | turn a list of values into a CSV line | [
"turn",
"a",
"list",
"of",
"values",
"into",
"a",
"CSV",
"line"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L778-L781 |
249,354 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_wp.py | WPModule.savecsv | def savecsv(self, filename):
'''save waypoints to a file in human-readable CSV file'''
f = open(filename, mode='w')
headers = ["Seq", "Frame", "Cmd", "P1", "P2", "P3", "P4", "X", "Y", "Z"]
print(self.csv_line(headers))
f.write(self.csv_line(headers) + "\n")
for w in self.... | python | def savecsv(self, filename):
'''save waypoints to a file in human-readable CSV file'''
f = open(filename, mode='w')
headers = ["Seq", "Frame", "Cmd", "P1", "P2", "P3", "P4", "X", "Y", "Z"]
print(self.csv_line(headers))
f.write(self.csv_line(headers) + "\n")
for w in self.... | [
"def",
"savecsv",
"(",
"self",
",",
"filename",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"mode",
"=",
"'w'",
")",
"headers",
"=",
"[",
"\"Seq\"",
",",
"\"Frame\"",
",",
"\"Cmd\"",
",",
"\"P1\"",
",",
"\"P2\"",
",",
"\"P3\"",
",",
"\"P4\"",
... | save waypoints to a file in human-readable CSV file | [
"save",
"waypoints",
"to",
"a",
"file",
"in",
"human",
"-",
"readable",
"CSV",
"file"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_wp.py#L787-L810 |
249,355 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_joystick/findjoy.py | list_joysticks | def list_joysticks():
'''Print a list of available joysticks'''
print('Available joysticks:')
print()
for jid in range(pygame.joystick.get_count()):
j = pygame.joystick.Joystick(jid)
print('({}) {}'.format(jid, j.get_name())) | python | def list_joysticks():
'''Print a list of available joysticks'''
print('Available joysticks:')
print()
for jid in range(pygame.joystick.get_count()):
j = pygame.joystick.Joystick(jid)
print('({}) {}'.format(jid, j.get_name())) | [
"def",
"list_joysticks",
"(",
")",
":",
"print",
"(",
"'Available joysticks:'",
")",
"print",
"(",
")",
"for",
"jid",
"in",
"range",
"(",
"pygame",
".",
"joystick",
".",
"get_count",
"(",
")",
")",
":",
"j",
"=",
"pygame",
".",
"joystick",
".",
"Joysti... | Print a list of available joysticks | [
"Print",
"a",
"list",
"of",
"available",
"joysticks"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_joystick/findjoy.py#L30-L37 |
249,356 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_joystick/findjoy.py | select_joystick | def select_joystick():
'''Allow user to select a joystick from a menu'''
list_joysticks()
while True:
print('Select a joystick (L to list, Q to quit)'),
choice = sys.stdin.readline().strip()
if choice.lower() == 'l':
list_joysticks()
elif choice.lower() == 'q':... | python | def select_joystick():
'''Allow user to select a joystick from a menu'''
list_joysticks()
while True:
print('Select a joystick (L to list, Q to quit)'),
choice = sys.stdin.readline().strip()
if choice.lower() == 'l':
list_joysticks()
elif choice.lower() == 'q':... | [
"def",
"select_joystick",
"(",
")",
":",
"list_joysticks",
"(",
")",
"while",
"True",
":",
"print",
"(",
"'Select a joystick (L to list, Q to quit)'",
")",
",",
"choice",
"=",
"sys",
".",
"stdin",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"if",
"c... | Allow user to select a joystick from a menu | [
"Allow",
"user",
"to",
"select",
"a",
"joystick",
"from",
"a",
"menu"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_joystick/findjoy.py#L40-L62 |
249,357 | ArduPilot/MAVProxy | MAVProxy/modules/lib/MacOS/wxversion.py | select | def select(versions, optionsRequired=False):
"""
Search for a wxPython installation that matches version. If one
is found then sys.path is modified so that version will be
imported with a 'import wx', otherwise a VersionError exception is
raised. This function should only be called once at the beg... | python | def select(versions, optionsRequired=False):
if type(versions) == str:
versions = [versions]
global _selected
if _selected is not None:
# A version was previously selected, ensure that it matches
# this new request
for ver in versions:
if _selected.Score(_wxPacka... | [
"def",
"select",
"(",
"versions",
",",
"optionsRequired",
"=",
"False",
")",
":",
"if",
"type",
"(",
"versions",
")",
"==",
"str",
":",
"versions",
"=",
"[",
"versions",
"]",
"global",
"_selected",
"if",
"_selected",
"is",
"not",
"None",
":",
"# A versio... | Search for a wxPython installation that matches version. If one
is found then sys.path is modified so that version will be
imported with a 'import wx', otherwise a VersionError exception is
raised. This function should only be called once at the beginning
of the application before wxPython is imported... | [
"Search",
"for",
"a",
"wxPython",
"installation",
"that",
"matches",
"version",
".",
"If",
"one",
"is",
"found",
"then",
"sys",
".",
"path",
"is",
"modified",
"so",
"that",
"version",
"will",
"be",
"imported",
"with",
"a",
"import",
"wx",
"otherwise",
"a",... | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/wxversion.py#L89-L159 |
249,358 | ArduPilot/MAVProxy | MAVProxy/modules/lib/MacOS/wxversion.py | ensureMinimal | def ensureMinimal(minVersion, optionsRequired=False):
"""
Checks to see if the default version of wxPython is greater-than
or equal to `minVersion`. If not then it will try to find an
installed version that is >= minVersion. If none are available
then a message is displayed that will inform the us... | python | def ensureMinimal(minVersion, optionsRequired=False):
assert type(minVersion) == str
# ensure that wxPython hasn't been imported yet.
if sys.modules.has_key('wx') or sys.modules.has_key('wxPython'):
raise AlreadyImportedError("wxversion.ensureMinimal() must be called before wxPython is imported")
... | [
"def",
"ensureMinimal",
"(",
"minVersion",
",",
"optionsRequired",
"=",
"False",
")",
":",
"assert",
"type",
"(",
"minVersion",
")",
"==",
"str",
"# ensure that wxPython hasn't been imported yet.",
"if",
"sys",
".",
"modules",
".",
"has_key",
"(",
"'wx'",
")",
"... | Checks to see if the default version of wxPython is greater-than
or equal to `minVersion`. If not then it will try to find an
installed version that is >= minVersion. If none are available
then a message is displayed that will inform the user and will
offer to open their web browser to the wxPython do... | [
"Checks",
"to",
"see",
"if",
"the",
"default",
"version",
"of",
"wxPython",
"is",
"greater",
"-",
"than",
"or",
"equal",
"to",
"minVersion",
".",
"If",
"not",
"then",
"it",
"will",
"try",
"to",
"find",
"an",
"installed",
"version",
"that",
"is",
">",
"... | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/wxversion.py#L168-L230 |
249,359 | ArduPilot/MAVProxy | MAVProxy/modules/lib/MacOS/wxversion.py | checkInstalled | def checkInstalled(versions, optionsRequired=False):
"""
Check if there is a version of wxPython installed that matches one
of the versions given. Returns True if so, False if not. This
can be used to determine if calling `select` will succeed or not.
:param versions: Same as in `select`, eit... | python | def checkInstalled(versions, optionsRequired=False):
if type(versions) == str:
versions = [versions]
installed = _find_installed()
bestMatch = _get_best_match(installed, versions, optionsRequired)
return bestMatch is not None | [
"def",
"checkInstalled",
"(",
"versions",
",",
"optionsRequired",
"=",
"False",
")",
":",
"if",
"type",
"(",
"versions",
")",
"==",
"str",
":",
"versions",
"=",
"[",
"versions",
"]",
"installed",
"=",
"_find_installed",
"(",
")",
"bestMatch",
"=",
"_get_be... | Check if there is a version of wxPython installed that matches one
of the versions given. Returns True if so, False if not. This
can be used to determine if calling `select` will succeed or not.
:param versions: Same as in `select`, either a string or a list
of strings specifying the vers... | [
"Check",
"if",
"there",
"is",
"a",
"version",
"of",
"wxPython",
"installed",
"that",
"matches",
"one",
"of",
"the",
"versions",
"given",
".",
"Returns",
"True",
"if",
"so",
"False",
"if",
"not",
".",
"This",
"can",
"be",
"used",
"to",
"determine",
"if",
... | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/wxversion.py#L235-L251 |
249,360 | ArduPilot/MAVProxy | MAVProxy/modules/lib/MacOS/wxversion.py | getInstalled | def getInstalled():
"""
Returns a list of strings representing the installed wxPython
versions that are found on the system.
"""
installed = _find_installed()
return [os.path.basename(p.pathname)[3:] for p in installed] | python | def getInstalled():
installed = _find_installed()
return [os.path.basename(p.pathname)[3:] for p in installed] | [
"def",
"getInstalled",
"(",
")",
":",
"installed",
"=",
"_find_installed",
"(",
")",
"return",
"[",
"os",
".",
"path",
".",
"basename",
"(",
"p",
".",
"pathname",
")",
"[",
"3",
":",
"]",
"for",
"p",
"in",
"installed",
"]"
] | Returns a list of strings representing the installed wxPython
versions that are found on the system. | [
"Returns",
"a",
"list",
"of",
"strings",
"representing",
"the",
"installed",
"wxPython",
"versions",
"that",
"are",
"found",
"on",
"the",
"system",
"."
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/wxversion.py#L255-L261 |
249,361 | ArduPilot/MAVProxy | MAVProxy/tools/MAVExplorer.py | flightmode_colours | def flightmode_colours():
'''return mapping of flight mode to colours'''
from MAVProxy.modules.lib.grapher import flightmode_colours
mapping = {}
idx = 0
for (mode,t0,t1) in flightmodes:
if not mode in mapping:
mapping[mode] = flightmode_colours[idx]
idx += 1
... | python | def flightmode_colours():
'''return mapping of flight mode to colours'''
from MAVProxy.modules.lib.grapher import flightmode_colours
mapping = {}
idx = 0
for (mode,t0,t1) in flightmodes:
if not mode in mapping:
mapping[mode] = flightmode_colours[idx]
idx += 1
... | [
"def",
"flightmode_colours",
"(",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"lib",
".",
"grapher",
"import",
"flightmode_colours",
"mapping",
"=",
"{",
"}",
"idx",
"=",
"0",
"for",
"(",
"mode",
",",
"t0",
",",
"t1",
")",
"in",
"flightmodes",
"... | return mapping of flight mode to colours | [
"return",
"mapping",
"of",
"flight",
"mode",
"to",
"colours"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/tools/MAVExplorer.py#L279-L290 |
249,362 | ArduPilot/MAVProxy | MAVProxy/tools/MAVExplorer.py | cmd_fft | def cmd_fft(args):
'''display fft from log'''
from MAVProxy.modules.lib import mav_fft
if len(args) > 0:
condition = args[0]
else:
condition = None
child = multiproc.Process(target=mav_fft.mavfft_display, args=[mestate.filename,condition])
child.start() | python | def cmd_fft(args):
'''display fft from log'''
from MAVProxy.modules.lib import mav_fft
if len(args) > 0:
condition = args[0]
else:
condition = None
child = multiproc.Process(target=mav_fft.mavfft_display, args=[mestate.filename,condition])
child.start() | [
"def",
"cmd_fft",
"(",
"args",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"lib",
"import",
"mav_fft",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
"condition",
"=",
"args",
"[",
"0",
"]",
"else",
":",
"condition",
"=",
"None",
"child",
"="... | display fft from log | [
"display",
"fft",
"from",
"log"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/tools/MAVExplorer.py#L354-L362 |
249,363 | ArduPilot/MAVProxy | MAVProxy/tools/MAVExplorer.py | cmd_save | def cmd_save(args):
'''save a graph'''
child = multiproc.Process(target=save_process, args=[mestate.last_graph, mestate.child_pipe_send_console, mestate.child_pipe_send_graph, mestate.status.msgs])
child.start() | python | def cmd_save(args):
'''save a graph'''
child = multiproc.Process(target=save_process, args=[mestate.last_graph, mestate.child_pipe_send_console, mestate.child_pipe_send_graph, mestate.status.msgs])
child.start() | [
"def",
"cmd_save",
"(",
"args",
")",
":",
"child",
"=",
"multiproc",
".",
"Process",
"(",
"target",
"=",
"save_process",
",",
"args",
"=",
"[",
"mestate",
".",
"last_graph",
",",
"mestate",
".",
"child_pipe_send_console",
",",
"mestate",
".",
"child_pipe_sen... | save a graph | [
"save",
"a",
"graph"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/tools/MAVExplorer.py#L450-L453 |
249,364 | ArduPilot/MAVProxy | MAVProxy/tools/MAVExplorer.py | cmd_loadfile | def cmd_loadfile(args):
'''callback from menu to load a log file'''
if len(args) != 1:
fileargs = " ".join(args)
else:
fileargs = args[0]
if not os.path.exists(fileargs):
print("Error loading file ", fileargs);
return
if os.name == 'nt':
#convert slashes in Wi... | python | def cmd_loadfile(args):
'''callback from menu to load a log file'''
if len(args) != 1:
fileargs = " ".join(args)
else:
fileargs = args[0]
if not os.path.exists(fileargs):
print("Error loading file ", fileargs);
return
if os.name == 'nt':
#convert slashes in Wi... | [
"def",
"cmd_loadfile",
"(",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
":",
"fileargs",
"=",
"\" \"",
".",
"join",
"(",
"args",
")",
"else",
":",
"fileargs",
"=",
"args",
"[",
"0",
"]",
"if",
"not",
"os",
".",
"path",
".",
"exi... | callback from menu to load a log file | [
"callback",
"from",
"menu",
"to",
"load",
"a",
"log",
"file"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/tools/MAVExplorer.py#L499-L511 |
249,365 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_GPSInput.py | GPSInputModule.cmd_port | def cmd_port(self, args):
'handle port selection'
if len(args) != 1:
print("Usage: port <number>")
return
self.port.close()
self.portnum = int(args[0])
self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.port.setsockopt(socke... | python | def cmd_port(self, args):
'handle port selection'
if len(args) != 1:
print("Usage: port <number>")
return
self.port.close()
self.portnum = int(args[0])
self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.port.setsockopt(socke... | [
"def",
"cmd_port",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
":",
"print",
"(",
"\"Usage: port <number>\"",
")",
"return",
"self",
".",
"port",
".",
"close",
"(",
")",
"self",
".",
"portnum",
"=",
"int",
"(",
"ar... | handle port selection | [
"handle",
"port",
"selection"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_GPSInput.py#L97-L110 |
249,366 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_magical/wxvehicle.py | Vehicle.RunScript | def RunScript(self, script):
'''
Actuate on the vehicle through a script. The script is a sequence of
commands. Each command is a sequence with the first element as the
command name and the remaining values as parameters.
The script is executed asynchronously by a timer with a p... | python | def RunScript(self, script):
'''
Actuate on the vehicle through a script. The script is a sequence of
commands. Each command is a sequence with the first element as the
command name and the remaining values as parameters.
The script is executed asynchronously by a timer with a p... | [
"def",
"RunScript",
"(",
"self",
",",
"script",
")",
":",
"self",
".",
"script",
"=",
"script",
"self",
".",
"script_command",
"=",
"0",
"self",
".",
"script_command_start_time",
"=",
"0",
"self",
".",
"script_command_state",
"=",
"'ready'",
"self",
".",
"... | Actuate on the vehicle through a script. The script is a sequence of
commands. Each command is a sequence with the first element as the
command name and the remaining values as parameters.
The script is executed asynchronously by a timer with a period of 0.1
seconds. At each timer tick,... | [
"Actuate",
"on",
"the",
"vehicle",
"through",
"a",
"script",
".",
"The",
"script",
"is",
"a",
"sequence",
"of",
"commands",
".",
"Each",
"command",
"is",
"a",
"sequence",
"with",
"the",
"first",
"element",
"as",
"the",
"command",
"name",
"and",
"the",
"r... | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_magical/wxvehicle.py#L140-L178 |
249,367 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_ppp.py | PPPModule.ppp_read | def ppp_read(self, ppp_fd):
'''called from main select loop in mavproxy when the pppd child
sends us some data'''
buf = os.read(ppp_fd, 100)
if len(buf) == 0:
# EOF on the child fd
self.stop_ppp_link()
return
print("ppp packet len=%u" % len(buf... | python | def ppp_read(self, ppp_fd):
'''called from main select loop in mavproxy when the pppd child
sends us some data'''
buf = os.read(ppp_fd, 100)
if len(buf) == 0:
# EOF on the child fd
self.stop_ppp_link()
return
print("ppp packet len=%u" % len(buf... | [
"def",
"ppp_read",
"(",
"self",
",",
"ppp_fd",
")",
":",
"buf",
"=",
"os",
".",
"read",
"(",
"ppp_fd",
",",
"100",
")",
"if",
"len",
"(",
"buf",
")",
"==",
"0",
":",
"# EOF on the child fd",
"self",
".",
"stop_ppp_link",
"(",
")",
"return",
"print",
... | called from main select loop in mavproxy when the pppd child
sends us some data | [
"called",
"from",
"main",
"select",
"loop",
"in",
"mavproxy",
"when",
"the",
"pppd",
"child",
"sends",
"us",
"some",
"data"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_ppp.py#L23-L33 |
249,368 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_ppp.py | PPPModule.start_ppp_link | def start_ppp_link(self):
'''startup the link'''
cmd = ['pppd']
cmd.extend(self.command)
(self.pid, self.ppp_fd) = pty.fork()
if self.pid == 0:
os.execvp("pppd", cmd)
raise RuntimeError("pppd exited")
if self.ppp_fd == -1:
print("Failed... | python | def start_ppp_link(self):
'''startup the link'''
cmd = ['pppd']
cmd.extend(self.command)
(self.pid, self.ppp_fd) = pty.fork()
if self.pid == 0:
os.execvp("pppd", cmd)
raise RuntimeError("pppd exited")
if self.ppp_fd == -1:
print("Failed... | [
"def",
"start_ppp_link",
"(",
"self",
")",
":",
"cmd",
"=",
"[",
"'pppd'",
"]",
"cmd",
".",
"extend",
"(",
"self",
".",
"command",
")",
"(",
"self",
".",
"pid",
",",
"self",
".",
"ppp_fd",
")",
"=",
"pty",
".",
"fork",
"(",
")",
"if",
"self",
"... | startup the link | [
"startup",
"the",
"link"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_ppp.py#L35-L53 |
249,369 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_ppp.py | PPPModule.stop_ppp_link | def stop_ppp_link(self):
'''stop the link'''
if self.ppp_fd == -1:
return
try:
self.mpself.select_extra.pop(self.ppp_fd)
os.close(self.ppp_fd)
os.waitpid(self.pid, 0)
except Exception:
pass
self.pid = -1
self.ppp... | python | def stop_ppp_link(self):
'''stop the link'''
if self.ppp_fd == -1:
return
try:
self.mpself.select_extra.pop(self.ppp_fd)
os.close(self.ppp_fd)
os.waitpid(self.pid, 0)
except Exception:
pass
self.pid = -1
self.ppp... | [
"def",
"stop_ppp_link",
"(",
"self",
")",
":",
"if",
"self",
".",
"ppp_fd",
"==",
"-",
"1",
":",
"return",
"try",
":",
"self",
".",
"mpself",
".",
"select_extra",
".",
"pop",
"(",
"self",
".",
"ppp_fd",
")",
"os",
".",
"close",
"(",
"self",
".",
... | stop the link | [
"stop",
"the",
"link"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_ppp.py#L56-L68 |
249,370 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_ppp.py | PPPModule.cmd_ppp | def cmd_ppp(self, args):
'''set ppp parameters and start link'''
usage = "ppp <command|start|stop>"
if len(args) == 0:
print(usage)
return
if args[0] == "command":
if len(args) == 1:
print("ppp.command=%s" % " ".join(self.command))
... | python | def cmd_ppp(self, args):
'''set ppp parameters and start link'''
usage = "ppp <command|start|stop>"
if len(args) == 0:
print(usage)
return
if args[0] == "command":
if len(args) == 1:
print("ppp.command=%s" % " ".join(self.command))
... | [
"def",
"cmd_ppp",
"(",
"self",
",",
"args",
")",
":",
"usage",
"=",
"\"ppp <command|start|stop>\"",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"print",
"(",
"usage",
")",
"return",
"if",
"args",
"[",
"0",
"]",
"==",
"\"command\"",
":",
"if",
"len... | set ppp parameters and start link | [
"set",
"ppp",
"parameters",
"and",
"start",
"link"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_ppp.py#L71-L87 |
249,371 | ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_module.py | MPModule.module_matching | def module_matching(self, name):
'''Find a list of modules matching a wildcard pattern'''
import fnmatch
ret = []
for mname in self.mpstate.public_modules.keys():
if fnmatch.fnmatch(mname, name):
ret.append(self.mpstate.public_modules[mname])
return re... | python | def module_matching(self, name):
'''Find a list of modules matching a wildcard pattern'''
import fnmatch
ret = []
for mname in self.mpstate.public_modules.keys():
if fnmatch.fnmatch(mname, name):
ret.append(self.mpstate.public_modules[mname])
return re... | [
"def",
"module_matching",
"(",
"self",
",",
"name",
")",
":",
"import",
"fnmatch",
"ret",
"=",
"[",
"]",
"for",
"mname",
"in",
"self",
".",
"mpstate",
".",
"public_modules",
".",
"keys",
"(",
")",
":",
"if",
"fnmatch",
".",
"fnmatch",
"(",
"mname",
"... | Find a list of modules matching a wildcard pattern | [
"Find",
"a",
"list",
"of",
"modules",
"matching",
"a",
"wildcard",
"pattern"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_module.py#L63-L70 |
249,372 | ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_module.py | MPModule.get_time | def get_time(self):
'''get time, using ATTITUDE.time_boot_ms if in SITL with SIM_SPEEDUP != 1'''
systime = time.time() - self.mpstate.start_time_s
if not self.mpstate.is_sitl:
return systime
try:
speedup = int(self.get_mav_param('SIM_SPEEDUP',1))
except Ex... | python | def get_time(self):
'''get time, using ATTITUDE.time_boot_ms if in SITL with SIM_SPEEDUP != 1'''
systime = time.time() - self.mpstate.start_time_s
if not self.mpstate.is_sitl:
return systime
try:
speedup = int(self.get_mav_param('SIM_SPEEDUP',1))
except Ex... | [
"def",
"get_time",
"(",
"self",
")",
":",
"systime",
"=",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"mpstate",
".",
"start_time_s",
"if",
"not",
"self",
".",
"mpstate",
".",
"is_sitl",
":",
"return",
"systime",
"try",
":",
"speedup",
"=",
"int... | get time, using ATTITUDE.time_boot_ms if in SITL with SIM_SPEEDUP != 1 | [
"get",
"time",
"using",
"ATTITUDE",
".",
"time_boot_ms",
"if",
"in",
"SITL",
"with",
"SIM_SPEEDUP",
"!",
"=",
"1"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_module.py#L72-L83 |
249,373 | ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_module.py | MPModule.dist_string | def dist_string(self, val_meters):
'''return a distance as a string'''
if self.settings.dist_unit == 'nm':
return "%.1fnm" % (val_meters * 0.000539957)
if self.settings.dist_unit == 'miles':
return "%.1fmiles" % (val_meters * 0.000621371)
return "%um" % val_meters | python | def dist_string(self, val_meters):
'''return a distance as a string'''
if self.settings.dist_unit == 'nm':
return "%.1fnm" % (val_meters * 0.000539957)
if self.settings.dist_unit == 'miles':
return "%.1fmiles" % (val_meters * 0.000621371)
return "%um" % val_meters | [
"def",
"dist_string",
"(",
"self",
",",
"val_meters",
")",
":",
"if",
"self",
".",
"settings",
".",
"dist_unit",
"==",
"'nm'",
":",
"return",
"\"%.1fnm\"",
"%",
"(",
"val_meters",
"*",
"0.000539957",
")",
"if",
"self",
".",
"settings",
".",
"dist_unit",
... | return a distance as a string | [
"return",
"a",
"distance",
"as",
"a",
"string"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_module.py#L150-L156 |
249,374 | ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_module.py | MPModule.speed_convert_units | def speed_convert_units(self, val_ms):
'''return a speed in configured units'''
if self.settings.speed_unit == 'knots':
return val_ms * 1.94384
elif self.settings.speed_unit == 'mph':
return val_ms * 2.23694
return val_ms | python | def speed_convert_units(self, val_ms):
'''return a speed in configured units'''
if self.settings.speed_unit == 'knots':
return val_ms * 1.94384
elif self.settings.speed_unit == 'mph':
return val_ms * 2.23694
return val_ms | [
"def",
"speed_convert_units",
"(",
"self",
",",
"val_ms",
")",
":",
"if",
"self",
".",
"settings",
".",
"speed_unit",
"==",
"'knots'",
":",
"return",
"val_ms",
"*",
"1.94384",
"elif",
"self",
".",
"settings",
".",
"speed_unit",
"==",
"'mph'",
":",
"return"... | return a speed in configured units | [
"return",
"a",
"speed",
"in",
"configured",
"units"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_module.py#L170-L176 |
249,375 | ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_module.py | MPModule.set_prompt | def set_prompt(self, prompt):
'''set prompt for command line'''
if prompt and self.settings.vehicle_name:
# add in optional vehicle name
prompt = self.settings.vehicle_name + ':' + prompt
self.mpstate.rl.set_prompt(prompt) | python | def set_prompt(self, prompt):
'''set prompt for command line'''
if prompt and self.settings.vehicle_name:
# add in optional vehicle name
prompt = self.settings.vehicle_name + ':' + prompt
self.mpstate.rl.set_prompt(prompt) | [
"def",
"set_prompt",
"(",
"self",
",",
"prompt",
")",
":",
"if",
"prompt",
"and",
"self",
".",
"settings",
".",
"vehicle_name",
":",
"# add in optional vehicle name",
"prompt",
"=",
"self",
".",
"settings",
".",
"vehicle_name",
"+",
"':'",
"+",
"prompt",
"se... | set prompt for command line | [
"set",
"prompt",
"for",
"command",
"line"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_module.py#L184-L189 |
249,376 | ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_module.py | MPModule.link_label | def link_label(link):
'''return a link label as a string'''
if hasattr(link, 'label'):
label = link.label
else:
label = str(link.linknum+1)
return label | python | def link_label(link):
'''return a link label as a string'''
if hasattr(link, 'label'):
label = link.label
else:
label = str(link.linknum+1)
return label | [
"def",
"link_label",
"(",
"link",
")",
":",
"if",
"hasattr",
"(",
"link",
",",
"'label'",
")",
":",
"label",
"=",
"link",
".",
"label",
"else",
":",
"label",
"=",
"str",
"(",
"link",
".",
"linknum",
"+",
"1",
")",
"return",
"label"
] | return a link label as a string | [
"return",
"a",
"link",
"label",
"as",
"a",
"string"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_module.py#L192-L198 |
249,377 | ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_module.py | MPModule.is_primary_vehicle | def is_primary_vehicle(self, msg):
'''see if a msg is from our primary vehicle'''
sysid = msg.get_srcSystem()
if self.target_system == 0 or self.target_system == sysid:
return True
return False | python | def is_primary_vehicle(self, msg):
'''see if a msg is from our primary vehicle'''
sysid = msg.get_srcSystem()
if self.target_system == 0 or self.target_system == sysid:
return True
return False | [
"def",
"is_primary_vehicle",
"(",
"self",
",",
"msg",
")",
":",
"sysid",
"=",
"msg",
".",
"get_srcSystem",
"(",
")",
"if",
"self",
".",
"target_system",
"==",
"0",
"or",
"self",
".",
"target_system",
"==",
"sysid",
":",
"return",
"True",
"return",
"False... | see if a msg is from our primary vehicle | [
"see",
"if",
"a",
"msg",
"is",
"from",
"our",
"primary",
"vehicle"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_module.py#L200-L205 |
249,378 | ArduPilot/MAVProxy | MAVProxy/modules/lib/grapher.py | MavGraph.next_flightmode_colour | def next_flightmode_colour(self):
'''allocate a colour to be used for a flight mode'''
if self.flightmode_colour_index > len(flightmode_colours):
print("Out of colours; reusing")
self.flightmode_colour_index = 0
ret = flightmode_colours[self.flightmode_colour_index]
... | python | def next_flightmode_colour(self):
'''allocate a colour to be used for a flight mode'''
if self.flightmode_colour_index > len(flightmode_colours):
print("Out of colours; reusing")
self.flightmode_colour_index = 0
ret = flightmode_colours[self.flightmode_colour_index]
... | [
"def",
"next_flightmode_colour",
"(",
"self",
")",
":",
"if",
"self",
".",
"flightmode_colour_index",
">",
"len",
"(",
"flightmode_colours",
")",
":",
"print",
"(",
"\"Out of colours; reusing\"",
")",
"self",
".",
"flightmode_colour_index",
"=",
"0",
"ret",
"=",
... | allocate a colour to be used for a flight mode | [
"allocate",
"a",
"colour",
"to",
"be",
"used",
"for",
"a",
"flight",
"mode"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/grapher.py#L146-L153 |
249,379 | ArduPilot/MAVProxy | MAVProxy/modules/lib/grapher.py | MavGraph.flightmode_colour | def flightmode_colour(self, flightmode):
'''return colour to be used for rendering a flight mode background'''
if flightmode not in self.flightmode_colourmap:
self.flightmode_colourmap[flightmode] = self.next_flightmode_colour()
return self.flightmode_colourmap[flightmode] | python | def flightmode_colour(self, flightmode):
'''return colour to be used for rendering a flight mode background'''
if flightmode not in self.flightmode_colourmap:
self.flightmode_colourmap[flightmode] = self.next_flightmode_colour()
return self.flightmode_colourmap[flightmode] | [
"def",
"flightmode_colour",
"(",
"self",
",",
"flightmode",
")",
":",
"if",
"flightmode",
"not",
"in",
"self",
".",
"flightmode_colourmap",
":",
"self",
".",
"flightmode_colourmap",
"[",
"flightmode",
"]",
"=",
"self",
".",
"next_flightmode_colour",
"(",
")",
... | return colour to be used for rendering a flight mode background | [
"return",
"colour",
"to",
"be",
"used",
"for",
"rendering",
"a",
"flight",
"mode",
"background"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/grapher.py#L155-L159 |
249,380 | ArduPilot/MAVProxy | MAVProxy/modules/lib/grapher.py | MavGraph.setup_xrange | def setup_xrange(self, xrange):
'''setup plotting ticks on x axis'''
if self.xaxis:
return
xrange *= 24 * 60 * 60
interval = 1
intervals = [ 1, 2, 5, 10, 15, 30, 60, 120, 240, 300, 600,
900, 1800, 3600, 7200, 5*3600, 10*3600, 24*3600 ]
fo... | python | def setup_xrange(self, xrange):
'''setup plotting ticks on x axis'''
if self.xaxis:
return
xrange *= 24 * 60 * 60
interval = 1
intervals = [ 1, 2, 5, 10, 15, 30, 60, 120, 240, 300, 600,
900, 1800, 3600, 7200, 5*3600, 10*3600, 24*3600 ]
fo... | [
"def",
"setup_xrange",
"(",
"self",
",",
"xrange",
")",
":",
"if",
"self",
".",
"xaxis",
":",
"return",
"xrange",
"*=",
"24",
"*",
"60",
"*",
"60",
"interval",
"=",
"1",
"intervals",
"=",
"[",
"1",
",",
"2",
",",
"5",
",",
"10",
",",
"15",
",",... | setup plotting ticks on x axis | [
"setup",
"plotting",
"ticks",
"on",
"x",
"axis"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/grapher.py#L161-L173 |
249,381 | ArduPilot/MAVProxy | MAVProxy/modules/lib/grapher.py | MavGraph.xlim_changed | def xlim_changed(self, axsubplot):
'''called when x limits are changed'''
xrange = axsubplot.get_xbound()
xlim = axsubplot.get_xlim()
self.setup_xrange(xrange[1] - xrange[0])
if self.draw_events == 0:
# ignore limit change before first draw event
return
... | python | def xlim_changed(self, axsubplot):
'''called when x limits are changed'''
xrange = axsubplot.get_xbound()
xlim = axsubplot.get_xlim()
self.setup_xrange(xrange[1] - xrange[0])
if self.draw_events == 0:
# ignore limit change before first draw event
return
... | [
"def",
"xlim_changed",
"(",
"self",
",",
"axsubplot",
")",
":",
"xrange",
"=",
"axsubplot",
".",
"get_xbound",
"(",
")",
"xlim",
"=",
"axsubplot",
".",
"get_xlim",
"(",
")",
"self",
".",
"setup_xrange",
"(",
"xrange",
"[",
"1",
"]",
"-",
"xrange",
"[",... | called when x limits are changed | [
"called",
"when",
"x",
"limits",
"are",
"changed"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/grapher.py#L175-L186 |
249,382 | ArduPilot/MAVProxy | MAVProxy/modules/lib/grapher.py | MavGraph.timestamp_to_days | def timestamp_to_days(self, timestamp):
'''convert log timestamp to days'''
if self.tday_base is None:
try:
self.tday_base = matplotlib.dates.date2num(datetime.datetime.fromtimestamp(timestamp+self.timeshift))
self.tday_basetime = timestamp
except ... | python | def timestamp_to_days(self, timestamp):
'''convert log timestamp to days'''
if self.tday_base is None:
try:
self.tday_base = matplotlib.dates.date2num(datetime.datetime.fromtimestamp(timestamp+self.timeshift))
self.tday_basetime = timestamp
except ... | [
"def",
"timestamp_to_days",
"(",
"self",
",",
"timestamp",
")",
":",
"if",
"self",
".",
"tday_base",
"is",
"None",
":",
"try",
":",
"self",
".",
"tday_base",
"=",
"matplotlib",
".",
"dates",
".",
"date2num",
"(",
"datetime",
".",
"datetime",
".",
"fromti... | convert log timestamp to days | [
"convert",
"log",
"timestamp",
"to",
"days"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/grapher.py#L362-L373 |
249,383 | ArduPilot/MAVProxy | MAVProxy/modules/lib/grapher.py | MavGraph.xlim_change_check | def xlim_change_check(self, idx):
'''handle xlim change requests from queue'''
if not self.xlim_pipe[1].poll():
return
xlim = self.xlim_pipe[1].recv()
if xlim is None:
return
#print("recv: ", self.graph_num, xlim)
if self.ax1 is not None and xlim !... | python | def xlim_change_check(self, idx):
'''handle xlim change requests from queue'''
if not self.xlim_pipe[1].poll():
return
xlim = self.xlim_pipe[1].recv()
if xlim is None:
return
#print("recv: ", self.graph_num, xlim)
if self.ax1 is not None and xlim !... | [
"def",
"xlim_change_check",
"(",
"self",
",",
"idx",
")",
":",
"if",
"not",
"self",
".",
"xlim_pipe",
"[",
"1",
"]",
".",
"poll",
"(",
")",
":",
"return",
"xlim",
"=",
"self",
".",
"xlim_pipe",
"[",
"1",
"]",
".",
"recv",
"(",
")",
"if",
"xlim",
... | handle xlim change requests from queue | [
"handle",
"xlim",
"change",
"requests",
"from",
"queue"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/grapher.py#L429-L444 |
249,384 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_misc.py | MiscModule.cmd_lockup_autopilot | def cmd_lockup_autopilot(self, args):
'''lockup autopilot for watchdog testing'''
if len(args) > 0 and args[0] == 'IREALLYMEANIT':
print("Sending lockup command")
self.master.mav.command_long_send(self.settings.target_system, self.settings.target_component,
... | python | def cmd_lockup_autopilot(self, args):
'''lockup autopilot for watchdog testing'''
if len(args) > 0 and args[0] == 'IREALLYMEANIT':
print("Sending lockup command")
self.master.mav.command_long_send(self.settings.target_system, self.settings.target_component,
... | [
"def",
"cmd_lockup_autopilot",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"0",
"and",
"args",
"[",
"0",
"]",
"==",
"'IREALLYMEANIT'",
":",
"print",
"(",
"\"Sending lockup command\"",
")",
"self",
".",
"master",
".",
"mav",
... | lockup autopilot for watchdog testing | [
"lockup",
"autopilot",
"for",
"watchdog",
"testing"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_misc.py#L147-L155 |
249,385 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_misc.py | MiscModule.cmd_gethome | def cmd_gethome(self, args):
'''get home position'''
self.master.mav.command_long_send(self.settings.target_system,
0,
mavutil.mavlink.MAV_CMD_GET_HOME_POSITION,
0, 0, 0, 0, 0, 0... | python | def cmd_gethome(self, args):
'''get home position'''
self.master.mav.command_long_send(self.settings.target_system,
0,
mavutil.mavlink.MAV_CMD_GET_HOME_POSITION,
0, 0, 0, 0, 0, 0... | [
"def",
"cmd_gethome",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"master",
".",
"mav",
".",
"command_long_send",
"(",
"self",
".",
"settings",
".",
"target_system",
",",
"0",
",",
"mavutil",
".",
"mavlink",
".",
"MAV_CMD_GET_HOME_POSITION",
",",
"0",... | get home position | [
"get",
"home",
"position"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_misc.py#L215-L220 |
249,386 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_misc.py | MiscModule.cmd_led | def cmd_led(self, args):
'''send LED pattern as override'''
if len(args) < 3:
print("Usage: led RED GREEN BLUE <RATE>")
return
pattern = [0] * 24
pattern[0] = int(args[0])
pattern[1] = int(args[1])
pattern[2] = int(args[2])
if len(... | python | def cmd_led(self, args):
'''send LED pattern as override'''
if len(args) < 3:
print("Usage: led RED GREEN BLUE <RATE>")
return
pattern = [0] * 24
pattern[0] = int(args[0])
pattern[1] = int(args[1])
pattern[2] = int(args[2])
if len(... | [
"def",
"cmd_led",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"3",
":",
"print",
"(",
"\"Usage: led RED GREEN BLUE <RATE>\"",
")",
"return",
"pattern",
"=",
"[",
"0",
"]",
"*",
"24",
"pattern",
"[",
"0",
"]",
"=",
"int",
... | send LED pattern as override | [
"send",
"LED",
"pattern",
"as",
"override"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_misc.py#L222-L240 |
249,387 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_misc.py | MiscModule.cmd_oreoled | def cmd_oreoled(self, args):
'''send LED pattern as override, using OreoLED conventions'''
if len(args) < 4:
print("Usage: oreoled LEDNUM RED GREEN BLUE <RATE>")
return
lednum = int(args[0])
pattern = [0] * 24
pattern[0] = ord('R')
pattern[1] = ord... | python | def cmd_oreoled(self, args):
'''send LED pattern as override, using OreoLED conventions'''
if len(args) < 4:
print("Usage: oreoled LEDNUM RED GREEN BLUE <RATE>")
return
lednum = int(args[0])
pattern = [0] * 24
pattern[0] = ord('R')
pattern[1] = ord... | [
"def",
"cmd_oreoled",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"4",
":",
"print",
"(",
"\"Usage: oreoled LEDNUM RED GREEN BLUE <RATE>\"",
")",
"return",
"lednum",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
")",
"pattern",
"=",... | send LED pattern as override, using OreoLED conventions | [
"send",
"LED",
"pattern",
"as",
"override",
"using",
"OreoLED",
"conventions"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_misc.py#L242-L260 |
249,388 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_misc.py | MiscModule.cmd_playtune | def cmd_playtune(self, args):
'''send PLAY_TUNE message'''
if len(args) < 1:
print("Usage: playtune TUNE")
return
tune = args[0]
str1 = tune[0:30]
str2 = tune[30:]
if sys.version_info.major >= 3 and not isinstance(str1, bytes):
str1 = b... | python | def cmd_playtune(self, args):
'''send PLAY_TUNE message'''
if len(args) < 1:
print("Usage: playtune TUNE")
return
tune = args[0]
str1 = tune[0:30]
str2 = tune[30:]
if sys.version_info.major >= 3 and not isinstance(str1, bytes):
str1 = b... | [
"def",
"cmd_playtune",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"1",
":",
"print",
"(",
"\"Usage: playtune TUNE\"",
")",
"return",
"tune",
"=",
"args",
"[",
"0",
"]",
"str1",
"=",
"tune",
"[",
"0",
":",
"30",
"]",
"... | send PLAY_TUNE message | [
"send",
"PLAY_TUNE",
"message"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_misc.py#L269-L283 |
249,389 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_misc.py | MiscModule.cmd_devid | def cmd_devid(self, args):
'''decode device IDs from parameters'''
for p in self.mav_param.keys():
if p.startswith('COMPASS_DEV_ID'):
mp_util.decode_devid(self.mav_param[p], p)
if p.startswith('INS_') and p.endswith('_ID'):
mp_util.decode_devid(sel... | python | def cmd_devid(self, args):
'''decode device IDs from parameters'''
for p in self.mav_param.keys():
if p.startswith('COMPASS_DEV_ID'):
mp_util.decode_devid(self.mav_param[p], p)
if p.startswith('INS_') and p.endswith('_ID'):
mp_util.decode_devid(sel... | [
"def",
"cmd_devid",
"(",
"self",
",",
"args",
")",
":",
"for",
"p",
"in",
"self",
".",
"mav_param",
".",
"keys",
"(",
")",
":",
"if",
"p",
".",
"startswith",
"(",
"'COMPASS_DEV_ID'",
")",
":",
"mp_util",
".",
"decode_devid",
"(",
"self",
".",
"mav_pa... | decode device IDs from parameters | [
"decode",
"device",
"IDs",
"from",
"parameters"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_misc.py#L314-L320 |
249,390 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.add_menu | def add_menu(self, menu):
'''add to the default popup menu'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
self.default_popup.add(menu)
self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_popup, combine=True)) | python | def add_menu(self, menu):
'''add to the default popup menu'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
self.default_popup.add(menu)
self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_popup, combine=True)) | [
"def",
"add_menu",
"(",
"self",
",",
"menu",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"mavproxy_map",
"import",
"mp_slipmap",
"self",
".",
"default_popup",
".",
"add",
"(",
"menu",
")",
"self",
".",
"map",
".",
"add_object",
"(",
"mp_slipmap",
... | add to the default popup menu | [
"add",
"to",
"the",
"default",
"popup",
"menu"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L114-L118 |
249,391 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.colour_for_wp | def colour_for_wp(self, wp_num):
'''return a tuple describing the colour a waypoint should appear on the map'''
wp = self.module('wp').wploader.wp(wp_num)
command = wp.command
return self._colour_for_wp_command.get(command, (0,255,0)) | python | def colour_for_wp(self, wp_num):
'''return a tuple describing the colour a waypoint should appear on the map'''
wp = self.module('wp').wploader.wp(wp_num)
command = wp.command
return self._colour_for_wp_command.get(command, (0,255,0)) | [
"def",
"colour_for_wp",
"(",
"self",
",",
"wp_num",
")",
":",
"wp",
"=",
"self",
".",
"module",
"(",
"'wp'",
")",
".",
"wploader",
".",
"wp",
"(",
"wp_num",
")",
"command",
"=",
"wp",
".",
"command",
"return",
"self",
".",
"_colour_for_wp_command",
"."... | return a tuple describing the colour a waypoint should appear on the map | [
"return",
"a",
"tuple",
"describing",
"the",
"colour",
"a",
"waypoint",
"should",
"appear",
"on",
"the",
"map"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L175-L179 |
249,392 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.label_for_waypoint | def label_for_waypoint(self, wp_num):
'''return the label the waypoint which should appear on the map'''
wp = self.module('wp').wploader.wp(wp_num)
command = wp.command
if command not in self._label_suffix_for_wp_command:
return str(wp_num)
return str(wp_num) + "(" + ... | python | def label_for_waypoint(self, wp_num):
'''return the label the waypoint which should appear on the map'''
wp = self.module('wp').wploader.wp(wp_num)
command = wp.command
if command not in self._label_suffix_for_wp_command:
return str(wp_num)
return str(wp_num) + "(" + ... | [
"def",
"label_for_waypoint",
"(",
"self",
",",
"wp_num",
")",
":",
"wp",
"=",
"self",
".",
"module",
"(",
"'wp'",
")",
".",
"wploader",
".",
"wp",
"(",
"wp_num",
")",
"command",
"=",
"wp",
".",
"command",
"if",
"command",
"not",
"in",
"self",
".",
... | return the label the waypoint which should appear on the map | [
"return",
"the",
"label",
"the",
"waypoint",
"which",
"should",
"appear",
"on",
"the",
"map"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L181-L187 |
249,393 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.remove_mission_nofly | def remove_mission_nofly(self, key, selection_index):
'''remove a mission nofly polygon'''
if not self.validate_nofly():
print("NoFly invalid")
return
print("NoFly valid")
idx = self.selection_index_to_idx(key, selection_index)
wploader = self.module('wp'... | python | def remove_mission_nofly(self, key, selection_index):
'''remove a mission nofly polygon'''
if not self.validate_nofly():
print("NoFly invalid")
return
print("NoFly valid")
idx = self.selection_index_to_idx(key, selection_index)
wploader = self.module('wp'... | [
"def",
"remove_mission_nofly",
"(",
"self",
",",
"key",
",",
"selection_index",
")",
":",
"if",
"not",
"self",
".",
"validate_nofly",
"(",
")",
":",
"print",
"(",
"\"NoFly invalid\"",
")",
"return",
"print",
"(",
"\"NoFly valid\"",
")",
"idx",
"=",
"self",
... | remove a mission nofly polygon | [
"remove",
"a",
"mission",
"nofly",
"polygon"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L345-L378 |
249,394 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.handle_menu_event | def handle_menu_event(self, obj):
'''handle a popup menu event from the map'''
menuitem = obj.menuitem
if menuitem.returnkey.startswith('# '):
cmd = menuitem.returnkey[2:]
if menuitem.handler is not None:
if menuitem.handler_result is None:
... | python | def handle_menu_event(self, obj):
'''handle a popup menu event from the map'''
menuitem = obj.menuitem
if menuitem.returnkey.startswith('# '):
cmd = menuitem.returnkey[2:]
if menuitem.handler is not None:
if menuitem.handler_result is None:
... | [
"def",
"handle_menu_event",
"(",
"self",
",",
"obj",
")",
":",
"menuitem",
"=",
"obj",
".",
"menuitem",
"if",
"menuitem",
".",
"returnkey",
".",
"startswith",
"(",
"'# '",
")",
":",
"cmd",
"=",
"menuitem",
".",
"returnkey",
"[",
"2",
":",
"]",
"if",
... | handle a popup menu event from the map | [
"handle",
"a",
"popup",
"menu",
"event",
"from",
"the",
"map"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L394-L421 |
249,395 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.map_callback | def map_callback(self, obj):
'''called when an event happens on the slipmap'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if isinstance(obj, mp_slipmap.SlipMenuEvent):
self.handle_menu_event(obj)
return
if not isinstance(obj, mp_slipmap.SlipMouseEvent):
... | python | def map_callback(self, obj):
'''called when an event happens on the slipmap'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if isinstance(obj, mp_slipmap.SlipMenuEvent):
self.handle_menu_event(obj)
return
if not isinstance(obj, mp_slipmap.SlipMouseEvent):
... | [
"def",
"map_callback",
"(",
"self",
",",
"obj",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"mavproxy_map",
"import",
"mp_slipmap",
"if",
"isinstance",
"(",
"obj",
",",
"mp_slipmap",
".",
"SlipMenuEvent",
")",
":",
"self",
".",
"handle_menu_event",
"(... | called when an event happens on the slipmap | [
"called",
"when",
"an",
"event",
"happens",
"on",
"the",
"slipmap"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L424-L477 |
249,396 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.drawing_end | def drawing_end(self):
'''end line drawing'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if self.draw_callback is None:
return
self.draw_callback(self.draw_line)
self.draw_callback = None
self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_p... | python | def drawing_end(self):
'''end line drawing'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if self.draw_callback is None:
return
self.draw_callback(self.draw_line)
self.draw_callback = None
self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_p... | [
"def",
"drawing_end",
"(",
"self",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"mavproxy_map",
"import",
"mp_slipmap",
"if",
"self",
".",
"draw_callback",
"is",
"None",
":",
"return",
"self",
".",
"draw_callback",
"(",
"self",
".",
"draw_line",
")",
... | end line drawing | [
"end",
"line",
"drawing"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L517-L525 |
249,397 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.draw_lines | def draw_lines(self, callback):
'''draw a series of connected lines on the map, calling callback when done'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
self.draw_callback = callback
self.draw_line = []
self.map.add_object(mp_slipmap.SlipDefaultPopup(None)) | python | def draw_lines(self, callback):
'''draw a series of connected lines on the map, calling callback when done'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
self.draw_callback = callback
self.draw_line = []
self.map.add_object(mp_slipmap.SlipDefaultPopup(None)) | [
"def",
"draw_lines",
"(",
"self",
",",
"callback",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"mavproxy_map",
"import",
"mp_slipmap",
"self",
".",
"draw_callback",
"=",
"callback",
"self",
".",
"draw_line",
"=",
"[",
"]",
"self",
".",
"map",
".",
... | draw a series of connected lines on the map, calling callback when done | [
"draw",
"a",
"series",
"of",
"connected",
"lines",
"on",
"the",
"map",
"calling",
"callback",
"when",
"done"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L527-L532 |
249,398 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.cmd_set_originpos | def cmd_set_originpos(self, args):
'''called when user selects "Set Origin" on map'''
(lat, lon) = (self.click_position[0], self.click_position[1])
print("Setting origin to: ", lat, lon)
self.master.mav.set_gps_global_origin_send(
self.settings.target_system,
lat*... | python | def cmd_set_originpos(self, args):
'''called when user selects "Set Origin" on map'''
(lat, lon) = (self.click_position[0], self.click_position[1])
print("Setting origin to: ", lat, lon)
self.master.mav.set_gps_global_origin_send(
self.settings.target_system,
lat*... | [
"def",
"cmd_set_originpos",
"(",
"self",
",",
"args",
")",
":",
"(",
"lat",
",",
"lon",
")",
"=",
"(",
"self",
".",
"click_position",
"[",
"0",
"]",
",",
"self",
".",
"click_position",
"[",
"1",
"]",
")",
"print",
"(",
"\"Setting origin to: \"",
",",
... | called when user selects "Set Origin" on map | [
"called",
"when",
"user",
"selects",
"Set",
"Origin",
"on",
"map"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L580-L588 |
249,399 | ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_map/__init__.py | MapModule.cmd_center | def cmd_center(self, args):
'''control center of view'''
if len(args) < 3:
print("map center LAT LON")
return
lat = float(args[1])
lon = float(args[2])
self.map.set_center(lat, lon) | python | def cmd_center(self, args):
'''control center of view'''
if len(args) < 3:
print("map center LAT LON")
return
lat = float(args[1])
lon = float(args[2])
self.map.set_center(lat, lon) | [
"def",
"cmd_center",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"<",
"3",
":",
"print",
"(",
"\"map center LAT LON\"",
")",
"return",
"lat",
"=",
"float",
"(",
"args",
"[",
"1",
"]",
")",
"lon",
"=",
"float",
"(",
"args",
... | control center of view | [
"control",
"center",
"of",
"view"
] | f50bdeff33064876f7dc8dc4683d278ff47f75d5 | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L598-L605 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.