def doupdatesite(self, pargs):
        hhvm = None
        pagespeed = None
        letsencrypt = False
        php7 = None


        data = dict()
        try:
            stype, cache = detSitePar(vars(pargs))
        except RuntimeError as e:
            Log.debug(self, str(e))
            Log.error(self, "Please provide valid options combination for"
                      " site update")

        if stype is None and pargs.proxy:
            stype, cache = 'proxy', ''
            proxyinfo = pargs.proxy[0].strip()
            if not proxyinfo:
                Log.error(self, "Please provide proxy server host information")
            proxyinfo = proxyinfo.split(':')
            host = proxyinfo[0].strip()
            port = '80' if len(proxyinfo) < 2 else proxyinfo[1].strip()
        elif stype is None and not (pargs.proxy or pargs.letsencrypt):
            stype, cache = 'html', 'basic'
        elif stype and pargs.proxy:
            Log.error(self, "--proxy can not be used with other site types")
        if (pargs.proxy and (pargs.pagespeed or pargs.hhvm)):
            Log.error(self, "Proxy site can not run on pagespeed or hhvm")

        if not pargs.site_name:
            try:
                while not pargs.site_name:
                    pargs.site_name = (input('Enter site name : ').strip())
            except IOError as e:
                Log.error(self, 'Unable to input site name, Please try again!')

        pargs.site_name = pargs.site_name.strip()
        (ee_domain,
         ee_www_domain, ) = ValidateDomain(pargs.site_name)
        ee_site_webroot = EEVariables.ee_webroot + ee_domain

        check_site = getSiteInfo(self, ee_domain)

        if check_site is None:
            Log.error(self, " Site {0} does not exist.".format(ee_domain))
        else:
            oldsitetype = check_site.site_type
            oldcachetype = check_site.cache_type
            old_hhvm = check_site.is_hhvm
            old_pagespeed = check_site.is_pagespeed
            check_ssl = check_site.is_ssl
            check_php_version = check_site.php_version

            if check_php_version == "7.0":
                old_php7 = True
            else:
                old_php7 = False

        if (pargs.password and not (pargs.html or
            pargs.php or pargs.php7 or pargs.mysql or pargs.wp or
            pargs.w3tc or pargs.wpfc or pargs.wpsc
           or pargs.wpsubdir or pargs.wpsubdomain)):
            try:
                updatewpuserpassword(self, ee_domain, ee_site_webroot)
            except SiteError as e:
                Log.debug(self, str(e))
                Log.info(self, "\nPassword Unchanged.")
            return 0

        if ((stype == "proxy" and stype == oldsitetype and self.app.pargs.hhvm)
            or (stype == "proxy" and
                stype == oldsitetype and self.app.pargs.pagespeed)):
                Log.info(self, Log.FAIL +
                         "Can not update proxy site to HHVM or Pagespeed")
                return 1
        if stype == "html" and stype == oldsitetype and self.app.pargs.hhvm:
            Log.info(self, Log.FAIL + "Can not update HTML site to HHVM")
            return 1

        if ((stype == 'php' and oldsitetype not in ['html', 'proxy', 'php7']) or
          #  (stype == 'php7' and oldsitetype not in ['html', 'mysql', 'php', 'php7', 'wp', 'wpsubdir', 'wpsubdomain', ]) or
            (stype == 'mysql' and oldsitetype not in ['html', 'php',
                                                      'proxy','php7']) or
            (stype == 'wp' and oldsitetype not in ['html', 'php', 'mysql',
                                                   'proxy', 'wp', 'php7']) or
            (stype == 'wpsubdir' and oldsitetype in ['wpsubdomain']) or
            (stype == 'wpsubdomain' and oldsitetype in ['wpsubdir']) or
           (stype == oldsitetype and cache == oldcachetype) and
                    not (pargs.pagespeed or pargs.php7)):
            Log.info(self, Log.FAIL + "can not update {0} {1} to {2} {3}".
                     format(oldsitetype, oldcachetype, stype, cache))
            return 1

        if stype == 'proxy':
            data['site_name'] = ee_domain
            data['www_domain'] = ee_www_domain
            data['proxy'] = True
            data['host'] = host
            data['port'] = port
            pagespeed = False
            hhvm = False
            data['webroot'] = ee_site_webroot
            data['currsitetype'] = oldsitetype
            data['currcachetype'] = oldcachetype

        if stype == 'php':
            data = dict(site_name=ee_domain, www_domain=ee_www_domain,
                        static=False,  basic=True, wp=False, w3tc=False,
                        wpfc=False, wpsc=False, wpredis=False, multisite=False,
                        wpsubdir=False, webroot=ee_site_webroot,
                        currsitetype=oldsitetype, currcachetype=oldcachetype)

        elif stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:

            data = dict(site_name=ee_domain, www_domain=ee_www_domain,
                        static=False,  basic=True, wp=False, w3tc=False,
                        wpfc=False, wpsc=False, wpredis=False, multisite=False,
                        wpsubdir=False, webroot=ee_site_webroot,
                        ee_db_name='', ee_db_user='', ee_db_pass='',
                        ee_db_host='',
                        currsitetype=oldsitetype, currcachetype=oldcachetype)

            if stype in ['wp', 'wpsubdir', 'wpsubdomain']:
                data['wp'] = True
                data['basic'] = False
                data[cache] = True
                if stype in ['wpsubdir', 'wpsubdomain']:
                    data['multisite'] = True
                    if stype == 'wpsubdir':
                        data['wpsubdir'] = True

        if pargs.pagespeed or pargs.hhvm or pargs.php7:
            if not data:
                data = dict(site_name=ee_domain, www_domain=ee_www_domain,
                            currsitetype=oldsitetype,
                            currcachetype=oldcachetype,
                            webroot=ee_site_webroot)
                stype = oldsitetype
                cache = oldcachetype
                if oldsitetype == 'html' or oldsitetype == 'proxy':
                    data['static'] = True
                    data['wp'] = False
                    data['multisite'] = False
                    data['wpsubdir'] = False
                elif oldsitetype == 'php' or oldsitetype == 'mysql':
                    data['static'] = False
                    data['wp'] = False
                    data['multisite'] = False
                    data['wpsubdir'] = False
                elif oldsitetype == 'wp':
                    data['static'] = False
                    data['wp'] = True
                    data['multisite'] = False
                    data['wpsubdir'] = False
                elif oldsitetype == 'wpsubdir':
                    data['static'] = False
                    data['wp'] = True
                    data['multisite'] = True
                    data['wpsubdir'] = True
                elif oldsitetype == 'wpsubdomain':
                    data['static'] = False
                    data['wp'] = True
                    data['multisite'] = True
                    data['wpsubdir'] = False

                if oldcachetype == 'basic':
                    data['basic'] = True
                    data['w3tc'] = False
                    data['wpfc'] = False
                    data['wpsc'] = False
                    data['wpredis'] = False
                elif oldcachetype == 'w3tc':
                    data['basic'] = False
                    data['w3tc'] = True
                    data['wpfc'] = False
                    data['wpsc'] = False
                    data['wpredis'] = False
                elif oldcachetype == 'wpfc':
                    data['basic'] = False
                    data['w3tc'] = False
                    data['wpfc'] = True
                    data['wpsc'] = False
                    data['wpredis'] = False
                elif oldcachetype == 'wpsc':
                    data['basic'] = False
                    data['w3tc'] = False
                    data['wpfc'] = False
                    data['wpsc'] = True
                    data['wpredis'] = False
                elif oldcachetype == 'wpredis':
                    data['basic'] = False
                    data['w3tc'] = False
                    data['wpfc'] = False
                    data['wpsc'] = False
                    data['wpredis'] = True

            if pargs.hhvm != 'off':
                data['hhvm'] = True
                hhvm = True
            elif pargs.hhvm == 'off':
                data['hhvm'] = False
                hhvm = False

            if pargs.pagespeed != 'off':
                data['pagespeed'] = True
                pagespeed = True
            elif pargs.pagespeed == 'off':
                data['pagespeed'] = False
                pagespeed = False

            if pargs.php7 == 'on' :
                data['php7'] = True
                php7 = True
                check_php_version= '7.0'
            elif pargs.php7 == 'off':
                data['php7'] = False
                php7 = False
                check_php_version = '5.6'

        if pargs.pagespeed:
            if pagespeed is old_pagespeed:
                if pagespeed is False:
                    Log.info(self, "Pagespeed is already disabled for given "
                             "site")
                elif pagespeed is True:
                    Log.info(self, "Pagespeed is already enabled for given "
                             "site")
                pargs.pagespeed = False

        if pargs.php7:
            if php7 is old_php7:
                if php7 is False:
                    Log.info(self, "PHP 7.0 is already disabled for given "
                             "site")
                elif php7 is True:
                    Log.info(self, "PHP 7.0 is already enabled for given "
                             "site")
                pargs.php7 = False

        #--letsencrypt=renew code goes here
        if pargs.letsencrypt == "renew" and not pargs.all:
            expiry_days = SSL.getExpirationDays(self,ee_domain)
            min_expiry_days = 30
            if check_ssl:
                if (expiry_days <= min_expiry_days):
                    renewLetsEncrypt(self,ee_domain)
                else:
                    Log.error(self,"More than 30 days left for certificate Expiry. Not renewing now.")

            else:
                Log.error(self,"Cannot RENEW ! SSL is not configured for given site .")

            Log.info(self, "SUCCESS: Certificate was successfully renewed For"
                           " https://{0}".format(ee_domain))
            if (SSL.getExpirationDays(self,ee_domain)>0):
                    Log.info(self, "Your cert will expire within " + str(SSL.getExpirationDays(self,ee_domain)) + " days.")
                    Log.info(self, "Expiration DATE: " + str(SSL.getExpirationDate(self,ee_domain)))

            else:
                    Log.warn(self, "Your cert already EXPIRED !. PLEASE renew soon . ")

        if pargs.all and pargs.letsencrypt == "renew":

            if check_ssl:
                expiry_days = SSL.getExpirationDays(self,ee_domain,True)
                if expiry_days < 0:
                    return 0
                min_expiry_days = 30
                if (expiry_days <= min_expiry_days):
                    renewLetsEncrypt(self,ee_domain)
                    Log.info(self, "SUCCESS: Certificate was successfully renewed For"
                               " https://{0}".format(ee_domain))
                else:
                    Log.info(self,"More than 60 days left for certificate Expiry. Not renewing now.\n")

                if (SSL.getExpirationDays(self,ee_domain)>0):
                        Log.info(self, "Your cert will expire within " + str(SSL.getExpirationDays(self,ee_domain)) + " days.")
                        Log.info(self, "Expiration DATE: \n\n" + str(SSL.getExpirationDate(self,ee_domain)))
                return 0
                #else:
                 #       Log.warn(self, "Your cert already EXPIRED ! .PLEASE renew soon . ")
            else:
                Log.info(self,"SSL not configured for site http://{0}".format(ee_domain))
                return 0

        if pargs.all and pargs.letsencrypt == "off":
            if letsencrypt is check_ssl:
                if letsencrypt is False:
                    Log.error(self, "SSl is not configured for given "
                             "site",False)
                    return 0

        if pargs.letsencrypt:
            if pargs.letsencrypt == 'on':
                data['letsencrypt'] = True
                letsencrypt = True
            elif pargs.letsencrypt == 'off':
                data['letsencrypt'] = False
                letsencrypt = False

            if letsencrypt is check_ssl:
                if letsencrypt is False:
                    Log.error(self, "SSl is not configured for given "
                             "site")
                elif letsencrypt is True:
                    Log.error(self, "SSl is already configured for given "
                             "site")
                pargs.letsencrypt = False

        if pargs.hhvm:
            if hhvm is old_hhvm:
                if hhvm is False:
                    Log.info(self, "HHVM is allready disabled for given "
                             "site")
                elif hhvm is True:
                    Log.info(self, "HHVM is allready enabled for given "
                             "site")

                pargs.hhvm = False

        if data and (not pargs.hhvm):
            if old_hhvm is True:
                data['hhvm'] = True
                hhvm = True
            else:
                data['hhvm'] = False
                hhvm = False

        if data and (not pargs.pagespeed):
            if old_pagespeed is True:
                data['pagespeed'] = True
                pagespeed = True
            else:
                data['pagespeed'] = False
                pagespeed = False

        if data and (not pargs.php7):
            if old_php7 is True:
                data['php7'] = True
                php7 = True
            else:
                data['php7'] = False
                php7 = False

        if pargs.pagespeed=="on" or pargs.hhvm=="on" or pargs.letsencrypt=="on" or pargs.php7=="on":
            if pargs.php7 == "on":
                if (not pargs.experimental):
                    Log.info(self, "PHP7.0 is experimental feature and it may not"
                             " work with all plugins of your site.\nYou can "
                             "disable it by passing --php7=off later.\nDo you wish"
                             " to enable PHP now for {0}?".format(ee_domain))

                    # Check prompt
                    check_prompt = input("Type \"y\" to continue [n]:")
                    if check_prompt != "Y" and check_prompt != "y":
                        Log.info(self, "Not using PHP 7.0 for site")
                        data['php7'] = False
                        php7 = False
                    else:
                        data['php7'] = True
                        php7 = True
                else:
                    data['php7'] = True
                    php7 = True

            if pargs.hhvm == "on":
                if (not pargs.experimental):
                    Log.info(self, "HHVM is experimental feature and it may not"
                             " work with all plugins of your site.\nYou can "
                             "disable it by passing --hhvm=off later.\nDo you wish"
                             " to enable HHVM now for {0}?".format(ee_domain))

                    # Check prompt
                    check_prompt = input("Type \"y\" to continue [n]:")
                    if check_prompt != "Y" and check_prompt != "y":
                        Log.info(self, "Not using HHVM for site")
                        data['hhvm'] = False
                        hhvm = False
                    else:
                        data['hhvm'] = True
                        hhvm = True
                else:
                    data['hhvm'] = True
                    hhvm = True

            if pargs.pagespeed=="on":
                if (not pargs.experimental):
                    Log.info(self, "PageSpeed is experimental feature and it may not"
                             " work with all CSS/JS/Cache of your site.\nYou can "
                             "disable it by passing --pagespeed=off later.\nDo you wish"
                             " to enable PageSpeed now for {0}?".format(ee_domain))

                    # Check prompt
                    check_prompt = input("Type \"y\" to continue [n]:")
                    if check_prompt != "Y" and check_prompt != "y":
                        Log.info(self, "Not using Pagespeed for given site")
                        data['pagespeed'] = False
                        pagespeed = False
                    else:
                        data['pagespeed'] = True
                        pagespeed = True
                else:
                    data['pagespeed'] = True
                    pagespeed = True

            if pargs.letsencrypt == "on":

                if (not pargs.experimental):

                    if oldsitetype in ['wpsubdomain']:
	                    Log.warn(self, "Wildcard domains are not supported in Lets Encrypt.\nWP SUBDOMAIN site will get SSL for primary site only.")

                    Log.info(self, "Letsencrypt is currently in beta phase."
                             " \nDo you wish"
                             " to enable SSl now for {0}?".format(ee_domain))

                    # Check prompt
                    check_prompt = input("Type \"y\" to continue [n]:")
                    if check_prompt != "Y" and check_prompt != "y":
                        Log.info(self, "Not using letsencrypt for site")
                        data['letsencrypt'] = False
                        letsencrypt = False
                    else:
                        data['letsencrypt'] = True
                        letsencrypt = True
                else:
                    data['letsencrypt'] = True
                    letsencrypt = True



        if pargs.wpredis and data['currcachetype'] != 'wpredis':
            if (not pargs.experimental):
                Log.info(self, "Redis is experimental feature and it may not"
                         " work with all plugins of your site.\nYou can "
                         "disable it by changing cache type later.\nDo you wish"
                         " to enable Redis now for {0}?".format(ee_domain))

                # Check prompt
                check_prompt = input("Type \"y\" to continue [n]: ")
                if check_prompt != "Y" and check_prompt != "y":
                    Log.error(self, "Not using Redis for site")
                    data['wpredis'] = False
                    data['basic'] = True
                    cache = 'basic'

        if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and (php7 is old_php7) and
            (stype == oldsitetype and cache == oldcachetype)):
            return 1

        if not data:
            Log.error(self, "Cannot update {0}, Invalid Options"
                      .format(ee_domain))

        ee_auth = site_package_check(self, stype)
        data['ee_db_name'] = check_site.db_name
        data['ee_db_user'] = check_site.db_user
        data['ee_db_pass'] = check_site.db_password
        data['ee_db_host'] = check_site.db_host
        data['old_pagespeed_status'] = check_site.is_pagespeed

        if not pargs.letsencrypt:
            try:
                pre_run_checks(self)
            except SiteError as e:
                Log.debug(self, str(e))
                Log.error(self, "NGINX configuration check failed.")

            try:
                sitebackup(self, data)
            except Exception as e:
                Log.debug(self, str(e))
                Log.info(self, Log.FAIL + "Check logs for reason "
                     "`tail /var/log/ee/ee.log` & Try Again!!!")
                return 1

            # setup NGINX configuration, and webroot
            try:
                setupdomain(self, data)
            except SiteError as e:
                Log.debug(self, str(e))
                Log.info(self, Log.FAIL + "Update site failed."
                     "Check logs for reason"
                     "`tail /var/log/ee/ee.log` & Try Again!!!")
                return 1

        if data.keys() in 'proxy' and data['proxy']:
            updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
                           hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False)
            Log.info(self, "Successfully updated site"
                     " http://{0}".format(ee_domain))
            return 0

        # Update pagespeed config
        if pargs.pagespeed:
            operateOnPagespeed(self, data)

        if pargs.letsencrypt:
            if data['letsencrypt'] is True:
                if not os.path.isfile("{0}/conf/nginx/ssl.conf.disabled"
                              .format(ee_site_webroot)):
                    setupLetsEncrypt(self, ee_domain)

                else:
                    EEFileUtils.mvfile(self, "{0}/conf/nginx/ssl.conf.disabled"
                               .format(ee_site_webroot),
                               '{0}/conf/nginx/ssl.conf'
                               .format(ee_site_webroot))

                httpsRedirect(self,ee_domain)
                Log.info(self,"Creating Cron Job for cert auto-renewal")
                EECron.setcron_weekly(self,'ee site update --le=renew --all 2> /dev/null'.format(ee_domain),'Renew all'
                                                                ' letsencrypt SSL cert. Set by EasyEngine')

                if not EEService.reload_service(self, 'nginx'):
                        Log.error(self, "service nginx reload failed. "
                          "check issues with `nginx -t` command")

                Log.info(self, "Congratulations! Successfully Configured SSl for Site "
                         " https://{0}".format(ee_domain))

                if (SSL.getExpirationDays(self,ee_domain)>0):
                    Log.info(self, "Your cert will expire within " + str(SSL.getExpirationDays(self,ee_domain)) + " days.")
                else:
                    Log.warn(self, "Your cert already EXPIRED ! .PLEASE renew soon . ")

            elif data['letsencrypt'] is False:
                if os.path.isfile("{0}/conf/nginx/ssl.conf"
                          .format(ee_site_webroot)):
                        Log.info(self,'Setting Nginx configuration')
                        EEFileUtils.mvfile(self, "{0}/conf/nginx/ssl.conf"
                                  .format(ee_site_webroot),
                                  '{0}/conf/nginx/ssl.conf.disabled'
                                  .format(ee_site_webroot))
                        httpsRedirect(self,ee_domain,False)
                        if not EEService.reload_service(self, 'nginx'):
                            Log.error(self, "service nginx reload failed. "
                                 "check issues with `nginx -t` command")
                        #Log.info(self,"Removing Cron Job set for cert auto-renewal")
                        #EECron.remove_cron(self,'ee site update {0} --le=renew --min_expiry_limit 30 2> \/dev\/null'.format(ee_domain))
                        Log.info(self, "Successfully Disabled SSl for Site "
                         " http://{0}".format(ee_domain))


            # Add nginx conf folder into GIT
            EEGit.add(self, ["{0}/conf/nginx".format(ee_site_webroot)],
                          msg="Adding letsencrypts config of site: {0}"
                        .format(ee_domain))
            updateSiteInfo(self, ee_domain, ssl=letsencrypt)
            return 0

        if stype == oldsitetype and cache == oldcachetype:

            # Service Nginx Reload
            if not EEService.reload_service(self, 'nginx'):
                Log.error(self, "service nginx reload failed. "
                          "check issues with `nginx -t` command")

            updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
                           hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False, php_version=check_php_version)

            Log.info(self, "Successfully updated site"
                     " http://{0}".format(ee_domain))
            return 0

        #if data['ee_db_name'] and not data['wp']:
        if 'ee_db_name' in data.keys() and not data['wp']:
            try:
                data = setupdatabase(self, data)
            except SiteError as e:
                Log.debug(self, str(e))
                Log.info(self, Log.FAIL + "Update site failed."
                         "Check logs for reason"
                         "`tail /var/log/ee/ee.log` & Try Again!!!")
                return 1
            try:
                eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
                                  encoding='utf-8', mode='w')
                eedbconfig.write("<?php \ndefine('DB_NAME', '{0}');"
                                 "\ndefine('DB_USER', '{1}'); "
                                 "\ndefine('DB_PASSWORD', '{2}');"
                                 "\ndefine('DB_HOST', '{3}');\n?>"
                                 .format(data['ee_db_name'],
                                         data['ee_db_user'],
                                         data['ee_db_pass'],
                                         data['ee_db_host']))
                eedbconfig.close()
            except IOError as e:
                Log.debug(self, str(e))
                Log.debug(self, "creating ee-config.php failed.")
                Log.info(self, Log.FAIL + "Update site failed. "
                         "Check logs for reason "
                         "`tail /var/log/ee/ee.log` & Try Again!!!")
                return 1

        # Setup WordPress if old sites are html/php/mysql sites
        if data['wp'] and oldsitetype in ['html', 'proxy', 'php', 'mysql']:
            try:
                ee_wp_creds = setupwordpress(self, data)
            except SiteError as e:
                Log.debug(self, str(e))
                Log.info(self, Log.FAIL + "Update site failed."
                         "Check logs for reason "
                         "`tail /var/log/ee/ee.log` & Try Again!!!")
                return 1

        # Uninstall unnecessary plugins
        if oldsitetype in ['wp', 'wpsubdir', 'wpsubdomain']:
            # Setup WordPress Network if update option is multisite
            # and oldsite is WordPress single site
            if data['multisite'] and oldsitetype == 'wp':
                try:
                    setupwordpressnetwork(self, data)
                except SiteError as e:
                    Log.debug(self, str(e))
                    Log.info(self, Log.FAIL + "Update site failed. "
                             "Check logs for reason"
                             " `tail /var/log/ee/ee.log` & Try Again!!!")
                    return 1

            if (oldcachetype == 'w3tc' or oldcachetype == 'wpfc' and
               not (data['w3tc'] or data['wpfc'])):
                try:
                    uninstallwp_plugin(self, 'w3-total-cache', data)
                except SiteError as e:
                    Log.debug(self, str(e))
                    Log.info(self, Log.FAIL + "Update site failed. "
                             "Check logs for reason"
                             " `tail /var/log/ee/ee.log` & Try Again!!!")
                    return 1

            if ((oldcachetype in ['w3tc', 'wpsc', 'basic', 'wpredis'] and
                (data['wpfc'])) or (oldsitetype == 'wp' and data['multisite'] and data['wpfc'])):
                try:
                    plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_fastcgi","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
                    setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
                except SiteError as e:
                    Log.debug(self, str(e))
                    Log.info(self, Log.FAIL + "Update nginx-helper settings failed. "
                             "Check logs for reason"
                             " `tail /var/log/ee/ee.log` & Try Again!!!")
                    return 1

            elif ((oldcachetype in ['w3tc', 'wpsc', 'basic', 'wpfc'] and
               (data['wpredis'])) or (oldsitetype == 'wp' and data['multisite'] and data['wpredis'])):
                try:
                    plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_redis","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
                    setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
                except SiteError as e:
                    Log.debug(self, str(e))
                    Log.info(self, Log.FAIL + "Update nginx-helper settings failed. "
                             "Check logs for reason"
                             " `tail /var/log/ee/ee.log` & Try Again!!!")
                    return 1
            else:
                try:
                    plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":0,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_redis","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
                    setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
                except SiteError as e:
                    Log.debug(self, str(e))
                    Log.info(self, Log.FAIL + "Update nginx-helper settings failed. "
                             "Check logs for reason"
                             " `tail /var/log/ee/ee.log` & Try Again!!!")
                    return 1

            if oldcachetype == 'wpsc' and not data['wpsc']:
                try:
                    uninstallwp_plugin(self, 'wp-super-cache', data)
                except SiteError as e:
                    Log.debug(self, str(e))
                    Log.info(self, Log.FAIL + "Update site failed."
                             "Check logs for reason"
                             " `tail /var/log/ee/ee.log` & Try Again!!!")
                    return 1

            if oldcachetype == 'wpredis' and not data['wpredis']:
                try:
                    uninstallwp_plugin(self, 'redis-cache', data)
                except SiteError as e:
                    Log.debug(self, str(e))
                    Log.info(self, Log.FAIL + "Update site failed."
                             "Check logs for reason"
                             " `tail /var/log/ee/ee.log` & Try Again!!!")
                    return 1

        if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and (data['w3tc']
           or data['wpfc']):
            try:
                installwp_plugin(self, 'w3-total-cache', data)
            except SiteError as e:
                Log.debug(self, str(e))
                Log.info(self, Log.FAIL + "Update site failed."
                         "Check logs for reason"
                         " `tail /var/log/ee/ee.log` & Try Again!!!")
                return 1

        if oldcachetype != 'wpsc' and data['wpsc']:
            try:
                installwp_plugin(self, 'wp-super-cache', data)
            except SiteError as e:
                Log.debug(self, str(e))
                Log.info(self, Log.FAIL + "Update site failed."
                         "Check logs for reason "
                         "`tail /var/log/ee/ee.log` & Try Again!!!")
                return 1

        if oldcachetype != 'wpredis' and data['wpredis']:
            try:
                if installwp_plugin(self, 'redis-cache', data):
                    #search for wp-config.php
                    if EEFileUtils.isexist(self,"{0}/wp-config.php".format(ee_site_webroot)):
                        config_path = '{0}/wp-config.php'.format(ee_site_webroot)
                    elif EEFileUtils.isexist(self,"{0}/htdocs/wp-config.php".format(ee_site_webroot)):
                        config_path = '{0}/htdocs/wp-config.php'.format(ee_site_webroot)
                    else:
                        Log.debug(self, "Updating wp-config.php failed. File could not be located.")
                        Log.error(self,"wp-config.php could not be located !!")
                        raise SiteError

                    if EEShellExec.cmd_exec(self, "grep -q \"WP_CACHE_KEY_SALT\" {0}"
                                                  .format(config_path)):
                        pass
                    else:
                        try:
                            wpconfig = open("{0}".format(config_path),
                                               encoding='utf-8', mode='a')
                            wpconfig.write("\n\ndefine( \'WP_CACHE_KEY_SALT\', \'{0}:\' );"
                                           .format(ee_domain))
                            wpconfig.close()
                        except IOError as e:
                            Log.debug(self, str(e))
                            Log.debug(self, "Updating wp-config.php failed.")
                            Log.warn(self, "Updating wp-config.php failed. "
                                           "Could not append:"
                                           "\ndefine( \'WP_CACHE_KEY_SALT\', \'{0}:\' );".format(ee_domain) +
                                           "\nPlease add manually")
            except SiteError as e:
                Log.debug(self, str(e))
                Log.info(self, Log.FAIL + "Update site failed."
                         "Check logs for reason "
                         "`tail /var/log/ee/ee.log` & Try Again!!!")
                return 1

        # Service Nginx Reload
        if not EEService.reload_service(self, 'nginx'):
            Log.error(self, "service nginx reload failed. "
                      "check issues with `nginx -t` command")

        EEGit.add(self, ["/etc/nginx"],
                  msg="{0} updated with {1} {2}"
                  .format(ee_www_domain, stype, cache))
        # Setup Permissions for webroot
        try:
            setwebrootpermissions(self, data['webroot'])
        except SiteError as e:
            Log.debug(self, str(e))
            Log.info(self, Log.FAIL + "Update site failed."
                     "Check logs for reason "
                     "`tail /var/log/ee/ee.log` & Try Again!!!")
            return 1

        if ee_auth and len(ee_auth):
            for msg in ee_auth:
                Log.info(self, Log.ENDC + msg)

        display_cache_settings(self, data)
        if data['wp'] and oldsitetype in ['html', 'php', 'mysql']:
            Log.info(self, "\n\n" + Log.ENDC + "WordPress admin user :"
                     " {0}".format(ee_wp_creds['wp_user']))
            Log.info(self, Log.ENDC + "WordPress admin password : {0}"
                     .format(ee_wp_creds['wp_pass']) + "\n\n")
        if oldsitetype in ['html', 'php'] and stype != 'php':
            updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
                           db_name=data['ee_db_name'],
                           db_user=data['ee_db_user'],
                           db_password=data['ee_db_pass'],
                           db_host=data['ee_db_host'], hhvm=hhvm,
                           pagespeed=pagespeed,ssl=True if check_site.is_ssl else False,php_version=check_php_version)
        else:
            updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
                           hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False,php_version=check_php_version)
        Log.info(self, "Successfully updated site"
                 " http://{0}".format(ee_domain))
        return 0
dataset/ETHPy150Open EasyEngine/easyengine/ee/cli/plugins/site.py/EESiteUpdateController.doupdatesite/swapped operands of `in`