From 4df7c761d3040c4a79c274a1ca44855e62c5c480 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 21 Feb 2020 20:51:04 +0100 Subject: [PATCH] ++stuff --- .../uncloud_api/management/__init__.py | 0 .../management/commands/__init__.py | 0 .../management/commands/snapshot.py | 29 +++++++++++++++++++ nicohack202002/uncloud/uncloud_api/models.py | 1 + 4 files changed, 30 insertions(+) create mode 100644 nicohack202002/uncloud/uncloud_api/management/__init__.py create mode 100644 nicohack202002/uncloud/uncloud_api/management/commands/__init__.py create mode 100644 nicohack202002/uncloud/uncloud_api/management/commands/snapshot.py diff --git a/nicohack202002/uncloud/uncloud_api/management/__init__.py b/nicohack202002/uncloud/uncloud_api/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nicohack202002/uncloud/uncloud_api/management/commands/__init__.py b/nicohack202002/uncloud/uncloud_api/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nicohack202002/uncloud/uncloud_api/management/commands/snapshot.py b/nicohack202002/uncloud/uncloud_api/management/commands/snapshot.py new file mode 100644 index 0000000..41d0e38 --- /dev/null +++ b/nicohack202002/uncloud/uncloud_api/management/commands/snapshot.py @@ -0,0 +1,29 @@ +import time +from django.conf import settings +from django.core.management.base import BaseCommand + +from uncloud_api import models + + +class Command(BaseCommand): + args = '' + help = 'VM Snapshot support' + + def add_arguments(self, parser): + parser.add_argument('command', type=str, help='Command') + + def handle(self, *args, **options): + print("Snapshotting") + #getattr(self, options['command'])(**options) + + @classmethod + def monitor(cls, **_): + while True: + try: + tweets = models.Reply.get_target_tweets() + responses = models.Reply.objects.values_list('tweet_id', flat=True) + new_tweets = [x for x in tweets if x.id not in responses] + models.Reply.send(new_tweets) + except TweepError as e: + print(e) + time.sleep(60) diff --git a/nicohack202002/uncloud/uncloud_api/models.py b/nicohack202002/uncloud/uncloud_api/models.py index 9d4291a..06e77ed 100644 --- a/nicohack202002/uncloud/uncloud_api/models.py +++ b/nicohack202002/uncloud/uncloud_api/models.py @@ -49,6 +49,7 @@ class Order(models.Model): on_delete=models.CASCADE) + class OrderReference(models.Model): """ An order can references another product / relate to it.