Load Sepa even though lxml is not installed
This commit is contained in:
parent
d23ccd38fa
commit
3e892baf47
26
TODO.md
26
TODO.md
|
@ -460,29 +460,3 @@ mkhomedir_helper or create ssh homes with bash.rc and such
|
||||||
|
|
||||||
|
|
||||||
# POSTFIX web traffic monitor '": uid=" from=<%(user)s>'
|
# POSTFIX web traffic monitor '": uid=" from=<%(user)s>'
|
||||||
|
|
||||||
# orchestra.server PING/SSH+uptime status
|
|
||||||
class ServerState(models.Model):
|
|
||||||
server = models.OneToOneField(Server)
|
|
||||||
ping = models.CharField(max_length=256)
|
|
||||||
uptime = models.CharField(max_length=256)
|
|
||||||
from orchestra.contrib.orchestration.models import Server
|
|
||||||
from orchestra.utils.sys import run, sshrun, joinall
|
|
||||||
def retrieve_state(servers):
|
|
||||||
uptimes = []
|
|
||||||
pings = []
|
|
||||||
for server in servers:
|
|
||||||
address = server.get_address()
|
|
||||||
ping = run('ping -c 1 %s' % address, async=True)
|
|
||||||
pings.append(ping)
|
|
||||||
uptime = sshrun(address, 'uptime', persist=True, async=True)
|
|
||||||
uptimes.append(uptime)
|
|
||||||
|
|
||||||
pings = joinall(pings, silent=True)
|
|
||||||
uptimes = joinall(uptimes, silent=True)
|
|
||||||
for ping in pings:
|
|
||||||
print(ping.stdout.splitlines()[-1])
|
|
||||||
|
|
||||||
for uptime in uptimes:
|
|
||||||
print(uptime.stdout)
|
|
||||||
retrieve_state(Server.objects.all())
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Server(models.Model):
|
||||||
address = NullableCharField(_("address"), max_length=256, blank=True,
|
address = NullableCharField(_("address"), max_length=256, blank=True,
|
||||||
validators=[OrValidator(validate_ip_address, validate_hostname)],
|
validators=[OrValidator(validate_ip_address, validate_hostname)],
|
||||||
null=True, unique=True, help_text=_(
|
null=True, unique=True, help_text=_(
|
||||||
"Optional IP address or domain name. Name field will be used if not provided.<br>"
|
"Optional IP address or domain name. If blank, name field will be used for address resolution.<br>"
|
||||||
"If the IP address never changes you can set this field and save DNS requests."))
|
"If the IP address never changes you can set this field and save DNS requests."))
|
||||||
description = models.TextField(_("description"), blank=True)
|
description = models.TextField(_("description"), blank=True)
|
||||||
os = models.CharField(_("operative system"), max_length=32,
|
os = models.CharField(_("operative system"), max_length=32,
|
||||||
|
|
|
@ -8,9 +8,6 @@ from orchestra.utils.python import import_class
|
||||||
from .. import settings
|
from .. import settings
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class PaymentMethod(plugins.Plugin):
|
class PaymentMethod(plugins.Plugin):
|
||||||
label_field = 'label'
|
label_field = 'label'
|
||||||
number_field = 'number'
|
number_field = 'number'
|
||||||
|
@ -24,10 +21,7 @@ class PaymentMethod(plugins.Plugin):
|
||||||
def get_plugins(cls):
|
def get_plugins(cls):
|
||||||
plugins = []
|
plugins = []
|
||||||
for cls in settings.PAYMENTS_ENABLED_METHODS:
|
for cls in settings.PAYMENTS_ENABLED_METHODS:
|
||||||
try:
|
|
||||||
plugins.append(import_class(cls))
|
plugins.append(import_class(cls))
|
||||||
except ImportError as exc:
|
|
||||||
logger.error('Error loading %s: %s' % (cls, exc))
|
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
def get_label(self):
|
def get_label(self):
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import datetime
|
import datetime
|
||||||
import lxml.builder
|
import logging
|
||||||
import os
|
import os
|
||||||
from lxml import etree
|
|
||||||
from lxml.builder import E
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
@ -17,6 +15,14 @@ from .. import settings
|
||||||
from .options import PaymentMethod
|
from .options import PaymentMethod
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import lxml
|
||||||
|
except ImportError:
|
||||||
|
logger.error('Error loading lxml, module not install')
|
||||||
|
|
||||||
|
|
||||||
class SEPADirectDebitForm(PluginDataForm):
|
class SEPADirectDebitForm(PluginDataForm):
|
||||||
iban = forms.CharField(label='IBAN',
|
iban = forms.CharField(label='IBAN',
|
||||||
widget=forms.TextInput(attrs={'size': '50'}))
|
widget=forms.TextInput(attrs={'size': '50'}))
|
||||||
|
@ -76,6 +82,8 @@ class SEPADirectDebit(PaymentMethod):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def process_credits(cls, transactions):
|
def process_credits(cls, transactions):
|
||||||
|
import lxml.builder
|
||||||
|
from lxml.builder import E
|
||||||
from ..models import TransactionProcess
|
from ..models import TransactionProcess
|
||||||
process = TransactionProcess.objects.create()
|
process = TransactionProcess.objects.create()
|
||||||
context = cls.get_context(transactions)
|
context = cls.get_context(transactions)
|
||||||
|
@ -120,6 +128,8 @@ class SEPADirectDebit(PaymentMethod):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def process_debts(cls, transactions):
|
def process_debts(cls, transactions):
|
||||||
|
import lxml.builder
|
||||||
|
from lxml.builder import E
|
||||||
from ..models import TransactionProcess
|
from ..models import TransactionProcess
|
||||||
process = TransactionProcess.objects.create()
|
process = TransactionProcess.objects.create()
|
||||||
context = cls.get_context(transactions)
|
context = cls.get_context(transactions)
|
||||||
|
@ -185,6 +195,8 @@ class SEPADirectDebit(PaymentMethod):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_debt_transactions(cls, transactions, process):
|
def get_debt_transactions(cls, transactions, process):
|
||||||
|
import lxml.builder
|
||||||
|
from lxml.builder import E
|
||||||
for transaction in transactions:
|
for transaction in transactions:
|
||||||
transaction.process = process
|
transaction.process = process
|
||||||
transaction.state = transaction.WAITTING_EXECUTION
|
transaction.state = transaction.WAITTING_EXECUTION
|
||||||
|
@ -228,6 +240,8 @@ class SEPADirectDebit(PaymentMethod):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_credit_transactions(transactions, process):
|
def get_credit_transactions(transactions, process):
|
||||||
|
import lxml.builder
|
||||||
|
from lxml.builder import E
|
||||||
for transaction in transactions:
|
for transaction in transactions:
|
||||||
transaction.process = process
|
transaction.process = process
|
||||||
transaction.state = transaction.WAITTING_EXECUTION
|
transaction.state = transaction.WAITTING_EXECUTION
|
||||||
|
@ -263,6 +277,8 @@ class SEPADirectDebit(PaymentMethod):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_header(cls, context, process):
|
def get_header(cls, context, process):
|
||||||
|
import lxml.builder
|
||||||
|
from lxml.builder import E
|
||||||
return E.GrpHdr( # Group Header
|
return E.GrpHdr( # Group Header
|
||||||
E.MsgId(str(process.id)), # Message Id
|
E.MsgId(str(process.id)), # Message Id
|
||||||
E.CreDtTm( # Creation Date Time
|
E.CreDtTm( # Creation Date Time
|
||||||
|
@ -284,6 +300,7 @@ class SEPADirectDebit(PaymentMethod):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def process_xml(cls, sepa, xsd, file_name, process):
|
def process_xml(cls, sepa, xsd, file_name, process):
|
||||||
|
from lxml import etree
|
||||||
# http://www.iso20022.org/documents/messages/1_0_version/pain/schemas/pain.008.001.02.zip
|
# http://www.iso20022.org/documents/messages/1_0_version/pain/schemas/pain.008.001.02.zip
|
||||||
path = os.path.dirname(os.path.realpath(__file__))
|
path = os.path.dirname(os.path.realpath(__file__))
|
||||||
xsd_path = os.path.join(path, xsd)
|
xsd_path = os.path.join(path, xsd)
|
||||||
|
|
Loading…
Reference in New Issue