Compare commits

...

2 commits

Author SHA1 Message Date
Rémi Oudin 22fa039f1b Remove debug print 2018-02-26 16:23:14 +01:00
Théophile Bastian e4ad8c7ce6 Towards a working XML export 2018-02-26 15:58:30 +01:00
2 changed files with 10 additions and 3 deletions

View file

@ -225,7 +225,6 @@ class PageGetter:
scheduler.fetching()
async with async_timeout.timeout(10):
async with self.session.get(self.url, verify_ssl=ssl) as resp:
print("Resp status %s" % resp.status)
try:
return await resp.text()
except UnicodeDecodeError:

View file

@ -115,17 +115,25 @@ class History(models.Model):
runnner.run()
self.save()
def to_xml(self, xml_root):
def to_xml(self, xml_root=None):
''' Exports the current history to xml '''
standalone = False
if xml_root is None:
standalone = True
xml_root = ET.Element('root')
hist_node = ET.Element("history", attrib={
'start-ts': self.start_ts,
'played': 1 if self.played else 0,
'user': self.user.pk,
})
xml_root.append(hist_node)
for entry in self.historyentry_set:
for entry in self.historyentry_set.all():
entry.to_xml(hist_node)
if standalone:
return xml_root
@staticmethod
def from_xml(xml_root):
''' Loads an history from an XML file '''