allocate_ads.py 703 B

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. #!/usr/bin/env python
  3. """
  4. """
  5. import sys
  6. import os
  7. #: current_dir - 2
  8. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  9. sys.path.insert(0, PROJECT_ROOT)
  10. from script.base import init_env, get_logger
  11. logger = get_logger(__name__)
  12. init_env(interactive=True)
  13. from apps.web.ad.models import Advertisement
  14. from apps.web.ad.utils import set_directed_ad_to_devices
  15. for ad in Advertisement.objects(status=True, fansType='official'):
  16. print 'ad %s ' % (ad.adId,)
  17. logicalCodes = [ _['logicalCode'] for _ in ad.devList ]
  18. set_directed_ad_to_devices(logicalCodes, ad)
  19. print 'finished'