forked from uncloud/uncloud
29 lines
872 B
Python
29 lines
872 B
Python
import time
|
|
from django.conf import settings
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from uncloud_api import models
|
|
|
|
|
|
class Command(BaseCommand):
|
|
args = '<None>'
|
|
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)
|