Compare commits
2 commits
67ad232533
...
22fa039f1b
Author | SHA1 | Date | |
---|---|---|---|
Rémi Oudin | 22fa039f1b | ||
Théophile Bastian | e4ad8c7ce6 |
|
@ -225,7 +225,6 @@ class PageGetter:
|
||||||
scheduler.fetching()
|
scheduler.fetching()
|
||||||
async with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
async with self.session.get(self.url, verify_ssl=ssl) as resp:
|
async with self.session.get(self.url, verify_ssl=ssl) as resp:
|
||||||
print("Resp status %s" % resp.status)
|
|
||||||
try:
|
try:
|
||||||
return await resp.text()
|
return await resp.text()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
|
|
|
@ -115,17 +115,25 @@ class History(models.Model):
|
||||||
runnner.run()
|
runnner.run()
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def to_xml(self, xml_root):
|
def to_xml(self, xml_root=None):
|
||||||
''' Exports the current history to xml '''
|
''' 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={
|
hist_node = ET.Element("history", attrib={
|
||||||
'start-ts': self.start_ts,
|
'start-ts': self.start_ts,
|
||||||
'played': 1 if self.played else 0,
|
'played': 1 if self.played else 0,
|
||||||
'user': self.user.pk,
|
'user': self.user.pk,
|
||||||
})
|
})
|
||||||
xml_root.append(hist_node)
|
xml_root.append(hist_node)
|
||||||
for entry in self.historyentry_set:
|
for entry in self.historyentry_set.all():
|
||||||
entry.to_xml(hist_node)
|
entry.to_xml(hist_node)
|
||||||
|
|
||||||
|
if standalone:
|
||||||
|
return xml_root
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_xml(xml_root):
|
def from_xml(xml_root):
|
||||||
''' Loads an history from an XML file '''
|
''' Loads an history from an XML file '''
|
||||||
|
|
Loading…
Reference in a new issue