Python relative imports in AWS Lambda fail with attempted relative import with no known parent package
In AWS Lambda if I attempt an explicit relative import like this
.
├── lambda_file.py
└── example.py
#!/usr/bin/env python3 | |
import json | |
import os | |
import sys | |
from configparser import ConfigParser | |
from datetime import datetime | |
from pathlib import Path | |
import boto3 |
# Entrar na pasta de certificados do sistema: | |
# Ubuntu anterior ao 18: | |
sudo mkdir /usr/share/ca-certificates/serpro/ | |
sudo cd /usr/share/ca-certificates/serpro/ | |
# Ubuntu 18: | |
sudo mkdir /usr/local/share/ca-certificates/serpro/ | |
cd /usr/local/share/ca-certificates/serpro/ | |
# Baixar os certificados do repositorio: | |
wget -r --no-check-certificate https://ccd.serpro.gov.br/serproacf/docs/ |
config vpn ipsec phase1-interface | |
edit <<ID>>-0 | |
set interface "wan1" | |
set dpd on-idle | |
set local-gw 192.168.179.2 | |
set dhgrp 2 | |
set proposal aes128-sha1 | |
set keylife 28800 | |
set remote-gw <<Remote-Global-IP-0>> | |
set psksecret <<Secret-Key-0>> |
# -*- coding: utf-8 -*- | |
# Print iterations progress | |
def print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_length=100): | |
""" | |
Call in a loop to create terminal progress bar | |
@params: | |
iteration - Required : current iteration (Int) | |
total - Required : total iterations (Int) | |
prefix - Optional : prefix string (Str) |
Long ago, the first time I read "The Pragmatic Programmer", I read some advice that really stuck with me.
"Don't Use Manual Procedures".
This in the chapter on Ubiquitous Automation. To summarize, they want you to automate all the things.
The trouble was that I hadn't much of an idea how to actually go
#!/usr/bin/python | |
# All SSH libraries for Python are junk (2011-10-13). | |
# Too low-level (libssh2), too buggy (paramiko), too complicated | |
# (both), too poor in features (no use of the agent, for instance) | |
# Here is the right solution today: | |
import subprocess | |
import sys |