Guest User

Untitled

a guest
Jan 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. import datetime as dt
  2. from pytz import timezone
  3. import pytz
  4. import django_wsgi
  5. from django.conf import settings
  6. from django.db import IntegrityError
  7.  
  8. from account.models import ParselyAPIKey, Publisher,Tier, ElasticSearchSettings
  9.  
  10. apikey_infos = [
  11. "thesouthern.com",
  12. "herald-review.com",
  13. "trib.com",
  14. "wiscnews.com",
  15. "jg-tc.com",
  16. "globegazette.com",
  17. "rapidcityjournal.com",
  18. "magicvalley.com",
  19. "cumberlink.com",
  20. "santamariatimes.com",
  21. "syvnews.com",
  22. "dailyjournalonline.com",
  23. "siouxcityjournal.com",
  24. "wcfcourier.com",
  25. "auburnpub.com",
  26. "lompocrecord.com",
  27. "mtstandard.com",
  28. "helenair.com",
  29. "beatricedailysun.com",
  30. "columbustelegram.com",
  31. "fremonttribune.com",
  32. "thetandd.com",
  33. "theworldlink.com",
  34. "napavalleyregister.com",
  35. "muscatinejournal.com",
  36. "democratherald.com",
  37. "bismarcktribune.com",
  38. "gazettetimes.com",
  39. "journaltimes.com",
  40. "elkodaily.com",
  41. "tdn.com",
  42. "winonadailynews.com",
  43. "chippewa.com",
  44. "maysville-online.com",
  45. "azdailysun.com",
  46. "lebanon-express.com",
  47. "hanfordsentinel.com",
  48. "ravallirepublic.com",
  49. "missoulian.com",
  50. "qconline.com",
  51. "missoulanews.com"
  52. ]
  53.  
  54. def main():
  55. publisher = Publisher.objects.get(name="Lee Enterprises")
  56. tier = Tier.objects.get(name="2_analytics_team")
  57. signup_date = dt.datetime.utcnow()
  58.  
  59. for apikey_info in apikey_infos:
  60. # fix an error in source data
  61. key = apikey_info.strip("/")
  62. existing = ParselyAPIKey.objects.filter(key=key)
  63. if not existing:
  64. apikey = ParselyAPIKey()
  65. print("Creating apikey {}".format(key))
  66. else:
  67. apikey = existing[0]
  68. print("Editing existing apikey {}".format(key))
  69. apikey.key = key
  70. apikey.publisher = publisher
  71. apikey.tier = tier
  72. apikey.is_active = True
  73. apikey.timezone = timezone('US/Central')
  74. apikey.signup_date = signup_date
  75. apikey.track_start_date = signup_date
  76. apikey.registration_date = signup_date
  77. apikey.save()
  78. apikey.es_settings = es_settings
  79. apikey.save()
  80.  
  81. if __name__ == "__main__":
  82. main()
Add Comment
Please, Sign In to add comment