def install_completed_client(compiled_dir, project_client):
 tmp_client_dir = os.path.join(_TMP_COMPILE_DIR, project_client)
 install_dir = os.path.join(_DEFAULT_INSTALL_DIR, project_client)
 old_install_dir = os.path.join(_DEFAULT_INSTALL_DIR, (project_client + '.old'))
 if (not os.path.exists(_DEFAULT_INSTALL_DIR)):
  os.mkdir(_DEFAULT_INSTALL_DIR)
 if os.path.isdir(tmp_client_dir):
  if os.path.isdir(old_install_dir):
   shutil.rmtree(old_install_dir)
  if os.path.isdir(install_dir):
   os.rename(install_dir, old_install_dir)
  try:
   os.rename(tmp_client_dir, install_dir)
   return True
  except Exception as err:
   shutil.rmtree(install_dir)
   shutil.copytree(old_install_dir, install_dir)
   logging.error('Copying old client: %s', err)
 else:
  logging.error('Compiled directory is gone, something went wrong')
 return False

def install_completed_client ( compiled_dir , project_client ) : tmp_client_dir = os . path . join ( _TMP_COMPILE_DIR , project_client ) install_dir = os . path . join ( _DEFAULT_INSTALL_DIR , project_client ) old_install_dir = os . path . join ( _DEFAULT_INSTALL_DIR , ( project_client + '.old' ) ) if ( not os . path . exists ( _DEFAULT_INSTALL_DIR ) ) : os . mkdir ( _DEFAULT_INSTALL_DIR ) if os . path . isdir ( tmp_client_dir ) : if os . path . isdir ( old_install_dir ) : shutil . rmtree ( old_install_dir ) if os . path . isdir ( install_dir ) : os . rename ( install_dir , old_install_dir ) try : os . rename ( tmp_client_dir , install_dir ) return True except Exception as err : shutil . rmtree ( install_dir ) shutil . copytree ( old_install_dir , install_dir ) logging . error ( 'Copying old client: %s' , err ) else : logging . error ( 'Compiled directory is gone, something went wrong' ) return False
remove old client directory if it exists .