Ошибка заключается в следующем:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/app/app/misuper/management/commands/enviar_facturas_erp_manual.py", line 46, in handle
message.send()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/mail/message.py", line 348, in send
return self.get_connection(fail_silently).send_messages([self])
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/mail/message.py", line 302, in get_connection
self.connection = get_connection(fail_silently=fail_silently)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/mail/__init__.py", line 36, in get_connection
klass = import_string(backend or settings.EMAIL_BACKEND)
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named smtp
Да, вы можете сказать мне, установить пакет (?), Но уже в приложении, во всех других процессах я могу отправлять электронные письма, кроме этогоscript!
Код отправки электронной почты:
message = EmailMessage("xxxx", "xxxx", "xxx@xxx",
["xxxx@xxxx"])
message.attach('xxx.csv', csvfile.getvalue(), 'text/csv')
message.send()
logger.info(len(send_orders))
Я запускаю сценарий в стандартном режиме 1X Dyno
Правка для кода команды:
class Command(BaseCommand):
def handle(self, *args, **options):
date_start = timezone.now() - relativedelta.relativedelta(days=1)
csvfile = StringIO.StringIO()
states = ['ORDER_DELIVERED', 'ORDER_DELIVERED_UNRATED', 'ORDER_DELIVERED_RATED']
send_orders = Order.objects.filter(state__in=states, date__lt=date_start, erp_sent=False).order_by('id')
file_rows = ["order", "client", "Fecha", "response ERP"]
csvwriter = csv.writer(csvfile)
csvwriter.writerow(file_rows)
for order in send_orders:
try:
odoo_manager = OdooERPManager()
send_bill_erp = odoo_manager.send_sale(order)
if str(send_bill_erp).find('creada') > 0:
order.erp_sent = True
order.save()
else:
csvwriter.writerow([order.id, order.client, order.delivery, send_bill_erp])
except Exception as e:
csvwriter.writerow([order.id, order.client, order.delivery, e])
logger.info(len(send_orders))
В Python 2.7 в стеке Cedar-14