Commit 33126ec5 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

black

parent 86882f58
......@@ -7,35 +7,43 @@ import asyncio
import sys
from asyncio.subprocess import DEVNULL, PIPE
DISTRIBUTIONS = '16.04 18.04 20.04 fedora28 fedora31 archlinux stretch buster centos7'.split()
DISTRIBUTIONS = (
"16.04 18.04 20.04 fedora28 fedora31 archlinux stretch buster centos7".split()
)
async def build_run(dist, verbose=False, parallel=1):
"""Build and run a dockerfile."""
cmd = f'docker build --build-arg DIST={dist} --build-arg PARALLEL={parallel} -t all/{dist} .'
cmd = f"docker build --build-arg DIST={dist} --build-arg PARALLEL={parallel} -t all/{dist} ."
if verbose:
print(f'+ {cmd}\r')
proc = await asyncio.create_subprocess_exec(*cmd.split(), stdout=DEVNULL, stderr=DEVNULL)
print(f"+ {cmd}\r")
proc = await asyncio.create_subprocess_exec(
*cmd.split(), stdout=DEVNULL, stderr=DEVNULL
)
await proc.wait()
if proc.returncode != 0:
print(f'{dist:10} build failed\r')
print(f"{dist:10} build failed\r")
return
cmd = f'docker run --rm -it all/{dist}'
cmd = f"docker run --rm -it all/{dist}"
if verbose:
print(f'+ {cmd}\r')
proc = await asyncio.create_subprocess_exec(*cmd.split(), stdout=PIPE, stderr=DEVNULL)
print(f"+ {cmd}\r")
proc = await asyncio.create_subprocess_exec(
*cmd.split(), stdout=PIPE, stderr=DEVNULL
)
stdout, _ = await proc.communicate()
stdout = stdout.decode().replace('\r\n', ' ')
stdout = stdout.decode().replace("\r\n", " ")
if proc.returncode == 0:
print(f'{dist:10} {stdout}\r')
print(f"{dist:10} {stdout}\r")
else:
print(f'{dist:10} run failed\r')
print(f"{dist:10} run failed\r")
if __name__ == '__main__':
if __name__ == "__main__":
loop = asyncio.get_event_loop()
if len(sys.argv) > 1:
loop.run_until_complete(build_run(sys.argv[1], verbose=True, parallel=8))
else:
loop.run_until_complete(asyncio.gather(*(build_run(dist) for dist in DISTRIBUTIONS)))
loop.run_until_complete(
asyncio.gather(*(build_run(dist) for dist in DISTRIBUTIONS))
)
loop.close()
......@@ -12,19 +12,23 @@ import numpy as np
import pinocchio
import tsid
with open('/dist') as f:
with open("/dist") as f:
dist = f.read()
if '20.04' in dist:
print('*' * 74)
print('{: <6s}'.format(sys.version.split()[0]))
if "20.04" in dist:
print("*" * 74)
print("{: <6s}".format(sys.version.split()[0]))
print(eigenpy.Quaternion(1, 2, 3, 4).norm())
print(hppfcl.Capsule(2, 3).computeVolume())
print(pinocchio.SE3.Identity().inverse())
print(example_robot_data.load('talos').model.nq)
print(example_robot_data.load("talos").model.nq)
URDF = "/talos_data/robots/talos_left_arm.urdf"
PATH = example_robot_data.robots_loader.getModelPath(URDF)
print(tsid.RobotWrapper(PATH + URDF, [PATH], False).na)
print(crocoddyl.ActionModelUnicycle().nr)
print(curves.bezier(np.array([[1, 2, 3], [4, 5, 6], [4, 5, 6], [4, 5, 6], [4, 5, 6]]), 0.2, 1.5).dim())
print(
curves.bezier(
np.array([[1, 2, 3], [4, 5, 6], [4, 5, 6], [4, 5, 6], [4, 5, 6]]), 0.2, 1.5
).dim()
)
print(multicontact_api.ContactModel().mu)
......@@ -13,11 +13,13 @@ setup(
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/stack-of-tasks/eigenpy",
install_requires=['numpy'],
cmake_minimum_required_version='3.1',
install_requires=["numpy"],
cmake_minimum_required_version="3.1",
classifiers=[
"Programming Language :: Python :: 2", "Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License", "Operating System :: POSIX :: Linux"
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX :: Linux",
],
python_requires='>=2.7',
python_requires=">=2.7",
)
......@@ -5,8 +5,10 @@ import eigenpy
class TestEigenpy(unittest.TestCase):
def test_trivial(self):
self.assertLess(abs(eigenpy.Quaternion(1, 2, 3, 4).norm() - 5.47722557505), 1e-7)
self.assertLess(
abs(eigenpy.Quaternion(1, 2, 3, 4).norm() - 5.47722557505), 1e-7
)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
from setuptools import setup
import os
def read_text(path):
with open(path) as f:
return f.read().decode('utf-8').strip()
return f.read().decode("utf-8").strip()
def data_files(*paths):
return [(root, [os.path.join(root, f) for f in files]) for path in paths for root, _, files in os.walk(path)]
return [
(root, [os.path.join(root, f) for f in files])
for path in paths
for root, _, files in os.walk(path)
]
setup(
name="example-robot-data",
packages=['example_robot_data'],
packages=["example_robot_data"],
description="Set of robot URDFs for benchmarking and developed examples.",
url="https://github.com/gepetto/example-robot-data",
install_requires=['pinocchio'],
install_requires=["pinocchio"],
data_files=data_files("include", "lib", "share"),
version=read_text('.version'),
version=read_text(".version"),
long_description=read_text("README.md"),
long_description_content_type="text/markdown",
classifiers=[
"Programming Language :: Python :: 2", "Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License", "Operating System :: POSIX :: Linux"
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX :: Linux",
],
python_requires='>=2.7',
python_requires=">=2.7",
)
......@@ -5,8 +5,8 @@ import example_robot_data
class TestPinocchio(unittest.TestCase):
def test_trivial(self):
self.assertEqual(example_robot_data.load('talos').model.nq, 39)
self.assertEqual(example_robot_data.load("talos").model.nq, 39)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
......@@ -13,11 +13,13 @@ setup(
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/humanoid-path-planner/hpp-fcl",
install_requires=['eigenpy'],
cmake_minimum_required_version='3.1',
install_requires=["eigenpy"],
cmake_minimum_required_version="3.1",
classifiers=[
"Programming Language :: Python :: 2", "Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License", "Operating System :: POSIX :: Linux"
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX :: Linux",
],
python_requires='>=2.7',
python_requires=">=2.7",
)
......@@ -8,5 +8,5 @@ class TestHPPFCL(unittest.TestCase):
self.assertLess(abs(hppfcl.Capsule(2, 3).computeVolume() - 71.2094334814), 1e-7)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
......@@ -13,11 +13,13 @@ setup(
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/stack-of-tasks/pinocchio",
install_requires=['hpp-fcl'],
cmake_minimum_required_version='3.1',
install_requires=["hpp-fcl"],
cmake_minimum_required_version="3.1",
classifiers=[
"Programming Language :: Python :: 2", "Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License", "Operating System :: POSIX :: Linux"
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX :: Linux",
],
python_requires='>=2.7',
python_requires=">=2.7",
)
......@@ -5,8 +5,11 @@ import pinocchio
class TestPinocchio(unittest.TestCase):
def test_trivial(self):
self.assertEqual(str(pinocchio.SE3.Identity().inverse()), ' R =\n1 0 0\n0 1 0\n0 0 1\n p = -0 -0 -0\n')
self.assertEqual(
str(pinocchio.SE3.Identity().inverse()),
" R =\n1 0 0\n0 1 0\n0 0 1\n p = -0 -0 -0\n",
)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
......@@ -13,18 +13,18 @@ from pathlib import Path
import auditwheel
POLICY = Path(auditwheel.__file__).parent / 'policy/policy.json'
POLICY = Path(auditwheel.__file__).parent / "policy/policy.json"
with POLICY.open() as f:
policies = json.load(f)
deps = []
for dep in Path(sys.argv[-1]).glob('*.libs'):
for dep in Path(sys.argv[-1]).glob("*.libs"):
deps.append(dep.name)
for lib in dep.glob('*.so*'):
for lib in dep.glob("*.so*"):
policies[-1]["lib_whitelist"].append(lib.name)
with POLICY.open('w') as f:
with POLICY.open("w") as f:
json.dump(policies, f)
print(''.join(f':$ORIGIN/../{dep}' for dep in deps))
print("".join(f":$ORIGIN/../{dep}" for dep in deps))
......@@ -6,15 +6,19 @@ from matrix_client.client import MatrixClient
from greet_newcomers import get_gepetto
HOME = 'https://matrix.laas.fr'
ROOM = '#gepetto:laas.fr'
HOME = "https://matrix.laas.fr"
ROOM = "#gepetto:laas.fr"
if __name__ == '__main__':
if __name__ == "__main__":
client = MatrixClient(HOME)
client.login(username=getpass.getuser(), password=getpass.getpass())
room = client.rooms[client.api.get_room_id(ROOM)]
members = [m.user_id.split(':')[0][1:] for m in room.get_joined_members() if m.user_id.endswith(':laas.fr')]
members = [
m.user_id.split(":")[0][1:]
for m in room.get_joined_members()
if m.user_id.endswith(":laas.fr")
]
for member in get_gepetto():
print('v' if member in members else 'x', member)
print("v" if member in members else "x", member)
......@@ -5,21 +5,22 @@ import sys
import requests
from bs4 import BeautifulSoup
URL = 'https://www.laas.fr/public/fr/'
URL = "https://www.laas.fr/public/fr/"
def find_in_directory(name):
req = requests.get(URL + 'searchuser', {'letter': name})
soup = BeautifulSoup(req.content, 'html.parser')
for guy in soup.find('div', class_='personnel').find_all('tr')[1:]:
if 'GEPETTO' in guy.text:
return URL + guy.find('a').attrs['href']
req = requests.get(URL + "searchuser", {"letter": name})
soup = BeautifulSoup(req.content, "html.parser")
for guy in soup.find("div", class_="personnel").find_all("tr")[1:]:
if "GEPETTO" in guy.text:
return URL + guy.find("a").attrs["href"]
if __name__ == '__main__':
if __name__ == "__main__":
if len(sys.argv) > 1:
print(find_in_directory(sys.argv[1]))
else:
from greet_newcomers import get_gepetto # noqa
for username in get_gepetto():
print(username.center(10), find_in_directory(username[1:]))
......@@ -9,7 +9,7 @@ from pathlib import Path
from ldap3 import Connection
HERE = Path(__file__).resolve().parent
SHELF = str(HERE / '.cache')
SHELF = str(HERE / ".cache")
def get_gepetto():
......@@ -17,7 +17,7 @@ def get_gepetto():
Get the old list of Gepetto members
"""
with shelve.open(SHELF) as shelf:
gepetto = shelf['gepetto'] if 'gepetto' in shelf else []
gepetto = shelf["gepetto"] if "gepetto" in shelf else []
return gepetto
......@@ -27,15 +27,18 @@ def whoami(gepetto):
The mail will be sent from this account
"""
with shelve.open(SHELF) as shelf:
me = shelf['me'] if 'me' in shelf else getuser()
me = shelf["me"] if "me" in shelf else getuser()
while me not in gepetto:
print("You (%s) dont's seem to be in the Gepetto group… What's your LAAS username ?" % me)
me = input('--> ')
print(
"You (%s) dont's seem to be in the Gepetto group… What's your LAAS username ?"
% me
)
me = input("--> ")
# remember this in the cache
with shelve.open(SHELF) as shelf:
shelf['me'] = me
shelf["me"] = me
return me
......@@ -44,20 +47,20 @@ def greet(to, sender):
"""
Send a greeting email to `to`
"""
if '@' not in sender:
sender = '%s@laas.fr' % sender
if "@" not in sender:
sender = "%s@laas.fr" % sender
if '@' not in to:
to = '%s@laas.fr' % to
if "@" not in to:
to = "%s@laas.fr" % to
with (HERE / 'template.txt').open() as f:
with (HERE / "template.txt").open() as f:
msg = MIMEText(f.read())
msg['Subject'] = 'Welcome in Gepetto !'
msg['From'] = sender
msg['To'] = to
msg['Bcc'] = sender
s = SMTP('mail.laas.fr')
msg["Subject"] = "Welcome in Gepetto !"
msg["From"] = sender
msg["To"] = to
msg["Bcc"] = sender
s = SMTP("mail.laas.fr")
s.send_message(msg)
s.quit()
......@@ -66,12 +69,12 @@ def get_gepetto_ldap():
"""
Get a new list of Gepetto members in the LDAP of the LAAS
"""
conn = Connection('ldap.laas.fr', auto_bind=True)
conn.search('dc=laas,dc=fr', '(o=gepetto)', attributes=['uid'])
conn = Connection("ldap.laas.fr", auto_bind=True)
conn.search("dc=laas,dc=fr", "(o=gepetto)", attributes=["uid"])
return [str(entry.uid) for entry in conn.entries]
if __name__ == '__main__':
if __name__ == "__main__":
# Get old and new list of members
gepetto = get_gepetto()
gepetto_ldap = get_gepetto_ldap()
......@@ -89,4 +92,4 @@ if __name__ == '__main__':
# Save the new list
with shelve.open(SHELF) as shelf:
shelf['gepetto'] = gepetto_ldap
shelf["gepetto"] = gepetto_ldap
......@@ -6,21 +6,28 @@ from zipfile import ZipFile
import requests
DOC = Path('/net/cubitus/projects/Partage_GEPETTO/Doc')
GITLAB = 'https://gitlab.laas.fr'
RAINBOARD = 'http://rainboard.laas.fr'
INDEX = DOC / 'index.html'
HEAD = DOC / 'index.head.html'
DOC = Path("/net/cubitus/projects/Partage_GEPETTO/Doc")
GITLAB = "https://gitlab.laas.fr"
RAINBOARD = "http://rainboard.laas.fr"
INDEX = DOC / "index.html"
HEAD = DOC / "index.head.html"
if __name__ == '__main__':
with INDEX.open('w') as f:
if __name__ == "__main__":
with INDEX.open("w") as f:
with HEAD.open() as head:
f.write(head.read())
for project, namespace, branch in sorted(requests.get('%s/doc' % RAINBOARD).json()['ret']):
url = '%s/%s/%s/-/jobs/artifacts/%s/download' % (GITLAB, namespace, project, branch)
for project, namespace, branch in sorted(
requests.get("%s/doc" % RAINBOARD).json()["ret"]
):
url = "%s/%s/%s/-/jobs/artifacts/%s/download" % (
GITLAB,
namespace,
project,
branch,
)
path = DOC / namespace / project / branch
r = requests.get(url, {'job': 'doc-coverage'}, stream=True)
r = requests.get(url, {"job": "doc-coverage"}, stream=True)
try:
z = ZipFile(BytesIO(r.content))
path.mkdir(parents=True, exist_ok=True)
......@@ -29,16 +36,20 @@ if __name__ == '__main__':
pass
if path.exists():
with INDEX.open('a') as f:
with INDEX.open("a") as f:
link = path.relative_to(DOC)
doxygen, coverage = link / 'doxygen-html', link / 'coverage'
print('<tr><td>%s</td><td>%s</td><td>%s</td><td>' % (project, namespace, branch), file=f)
doxygen, coverage = link / "doxygen-html", link / "coverage"
print(
"<tr><td>%s</td><td>%s</td><td>%s</td><td>"
% (project, namespace, branch),
file=f,
)
if (DOC / doxygen).is_dir():
print('<a href="%s">Doc</a>' % doxygen, file=f)
print('</td><td>', file=f)
print("</td><td>", file=f)
if (DOC / coverage).is_dir():
print('<a href="%s">Coverage</a>' % coverage, file=f)
print('</td></tr>', file=f)
print("</td></tr>", file=f)
with INDEX.open('a') as f:
print('</table></body></html>', file=f)
with INDEX.open("a") as f:
print("</table></body></html>", file=f)
......@@ -15,47 +15,52 @@ from wand.drawing import Drawing
from wand.image import Image
# Cache LDAP data
CACHE = Path('data/offices-ldap.json')
CACHE = Path("data/offices-ldap.json")
# Drawings constants
LOGO = 'data/logo-low-black.png'
LOGO = "data/logo-low-black.png"
DPCM = 300 / 2.54 # dot per cm @300DPI
WIDTH, HEIGHT = int(6 * DPCM), int(3 * DPCM) # door labels are 6cm x 3cm
NOT_OFFICES = ['Exterieur', 'BSalleGerardBauzil']
BAT_B = 'data/bat_b.png'
NOT_OFFICES = ["Exterieur", "BSalleGerardBauzil"]
BAT_B = "data/bat_b.png"
MAP_POSITIONS = [
('B181', 1600, 830),
('B185', 1600, 130),
('B61a', 1333, 1820),
('B63', 1333, 1500),
('B65', 1333, 1320),
('B67', 1333, 870),
('B69.1', 1333, 680),
('B69.2', 1333, 520),
('B90', 0, 130),
('B91', 0, 280),
('B92', 0, 430),
('B94', 0, 750),
("B181", 1600, 830),
("B185", 1600, 130),
("B61a", 1333, 1820),
("B63", 1333, 1500),
("B65", 1333, 1320),
("B67", 1333, 870),
("B69.1", 1333, 680),
("B69.2", 1333, 520),
("B90", 0, 130),
("B91", 0, 280),
("B92", 0, 430),
("B94", 0, 750),
]
class Gepettist(NamedTuple):
"""A Gepettist has a SurName and a GivenName."""
sn: str
gn: str
def __str__(self):
return f'{self.gn} {self.sn}'
return f"{self.gn} {self.sn}"
class Offices:
"""A dict with rooms as key and set of Gepettists as values, defaulting to empty set."""
def __init__(self, **offices):
self.data = defaultdict(set)
self.data.update(offices)
def __str__(self):
return '\n'.join(f'{room:5}: {", ".join(str(m) for m in members)}' for room, members in self.sorted().items())
return "\n".join(
f'{room:5}: {", ".join(str(m) for m in members)}'
for room, members in self.sorted().items()
)
def __getitem__(self, key):
return self.data[key]
......@@ -70,7 +75,11 @@ class Offices:
return self.data.items()
def sorted(self):
return {o: sorted(self.data[o]) for o in sorted(self.data) if o != 'Exterieur' and self.data[o]}
return {
o: sorted(self.data[o])
for o in sorted(self.data)
if o != "Exterieur" and self.data[o]
}
def dumps(self):
"""dump a sorted dict of offices with sorted lists of members as a JSON string"""
......@@ -79,25 +88,39 @@ class Offices:
@staticmethod
def loads(s):
"""constructor from a JSON string"""
return Offices(**{room: set(Gepettist(*m) for m in members) for room, members in loads(s).items()})
return Offices(
**{
room: set(Gepettist(*m) for m in members)
for room, members in loads(s).items()
}
)
# Stuff that is wrong in LDAP… We should fix that there
WRONG_OFFICE = {
'Exterieur': {('Nils', 'Hareng')},
'BSalleGerardBauzil': {('Quang Anh', 'Le')},
'B69.1': {('Guilhem', 'Saurel'), ('Pierre', 'Fernbach')},
'B90': {('Nicolas', 'Mansard')},
'B69.2': {('Dinh Vinh Thanh', 'Nguyen'), ('Filip', 'Becanovic')},
"Exterieur": {("Nils", "Hareng")},
"BSalleGerardBauzil": {("Quang Anh", "Le")},
"B69.1": {("Guilhem", "Saurel"), ("Pierre", "Fernbach")},
"B90": {("Nicolas", "Mansard")},