Upgrade from 4.9 fails if you have Active Directory groups configured

Problem: when you run upgrade from version 4.9 and you have Active Directory security groups configured as policy members upgrade fails with the following error.

2017-06-14 22:26:35,050 Importing policy 'sample' from folder './_import/data/safety/policies/sample' ...
2017-06-14 22:26:35,050         Importing globals ...
2017-06-14 22:26:35,052         Importing exclusions ...
2017-06-14 22:26:35,220         Importing members ...
Traceback (most recent call last):
  File "upgrade.py", line 1390, in <module>
    main()
  File "upgrade.py", line 1378, in main
    upgrader.upgrade(args.version, args.etc_dir)
  File "upgrade.py", line 1358, in upgrade
    SafetyUpgrader(self.safety, self.squid).upgrade(version, etc_dir)
  File "upgrade.py", line 1111, in upgrade
    PoliciesImporter(self.squid, self.safety).upgrade(version, etc_dir)
  File "upgrade.py", line 838, in upgrade
    self.upgrade_policy(version, f, n)
  File "upgrade.py", line 902, in upgrade_policy
    u.upgrade(version, policy_dir)
  File "upgrade.py", line 761, in upgrade
    u.upgrade(version, folder)
  File "upgrade.py", line 454, in upgrade
    self.upgrade_impl(version, os.path.join(folder, "members"))
  File "upgrade.py", line 507, in upgrade_impl
    pos = item.rfind(test_str1)
AttributeError: 'dict' object has no attribute 'rfind'

There is a bug in upgrade.py script. To fix it, open the /opt/websafety/var/console/upgrade.py script in text editor and change line 491 from:

if version.startswith("4.6") or version.startswith("4.7") or version.startswith("4.8"):

into:

if version in ["4.6", "4.7", "4.8", "4.9"]:

Please note tab/spaces are valid in Python code so do NOT change the whitespace symbols at the beginning of the string!