
import sys

from datetime import date
from main import app
from upload_s3 import set_metadata
from flask_frozen import Freezer

# cron is called with 3 arguments, should only run in the first week of month
cron_condition = len(sys.argv) == 3 and date.today().day > 8
force_update = len(sys.argv) == 2 and sys.argv[1] == 'freeze'

if len(sys.argv) > 1:  # if runserver is passed an argument
    if cron_condition or force_update:
        print "Cron succeeded"
        #freezer = Freezer(app)
        #freezer.freeze()
        #set_metadata()
else:
    app.run()


import sys

from datetime import date
from main import app
from upload_s3 import set_metadata
from flask_frozen import Freezer

# cron is called with 3 arguments, should only run in the first week of month
cron_condition = len(sys.argv) == 3 and date.today().day < 8
force_update = len(sys.argv) == 2 and sys.argv[1] == 'freeze'

if len(sys.argv) > 1:  # if runserver is passed an argument
    if cron_condition or force_update:
        freezer = Freezer(app)
        freezer.freeze()
        set_metadata()
else:
    app.run()

Complete testing, change back to production code
Complete testing, change back to production code

  
  import sys
  
  from datetime import date
  from main import app
  from upload_s3 import set_metadata
  from flask_frozen import Freezer
  
  # cron is called with 3 arguments, should only run in the first week of month
- cron_condition = len(sys.argv) == 3 and date.today().day > 8
+ cron_condition = len(sys.argv) == 3 and date.today().day < 8
  force_update = len(sys.argv) == 2 and sys.argv[1] == 'freeze'
  
  if len(sys.argv) > 1:  # if runserver is passed an argument
      if cron_condition or force_update:
-         print "Cron succeeded"
-         #freezer = Freezer(app)
+         freezer = Freezer(app)
-         #freezer.freeze()
+         freezer.freeze()
-         #set_metadata()
+         set_metadata()
  else:
      app.run()
  
Complete testing, change back to production code
## Code Before:

import sys

from datetime import date
from main import app
from upload_s3 import set_metadata
from flask_frozen import Freezer

# cron is called with 3 arguments, should only run in the first week of month
cron_condition = len(sys.argv) == 3 and date.today().day > 8
force_update = len(sys.argv) == 2 and sys.argv[1] == 'freeze'

if len(sys.argv) > 1:  # if runserver is passed an argument
    if cron_condition or force_update:
        print "Cron succeeded"
        #freezer = Freezer(app)
        #freezer.freeze()
        #set_metadata()
else:
    app.run()

## Instruction:
Complete testing, change back to production code
## Code After:

import sys

from datetime import date
from main import app
from upload_s3 import set_metadata
from flask_frozen import Freezer

# cron is called with 3 arguments, should only run in the first week of month
cron_condition = len(sys.argv) == 3 and date.today().day < 8
force_update = len(sys.argv) == 2 and sys.argv[1] == 'freeze'

if len(sys.argv) > 1:  # if runserver is passed an argument
    if cron_condition or force_update:
        freezer = Freezer(app)
        freezer.freeze()
        set_metadata()
else:
    app.run()
