def clean(self, pNetworkLoc=''):
        _pNetworkLoc = pNetworkLoc

        # clean pymel
        pymel102 = Path('%s/python/maya/pymel-1.0.2' % _pNetworkLoc)
        if pymel102.exists():
            print "Cleaning old: %s/." % _pNetworkLoc
            for _dir in pymel102.dirs():
                # make writable
                for _file in _dir.walk():
                    _file.makeWritable()

                if _dir.exists():
                    try:
                        _dir.rmtree()
                        print "Removing dir: %s" % _dir
                    except WindowsError:
                        print "Unable to delete dir: '%s'" % _dir
                        raise
            # remote top dir too
            pymel102.rmtree()

        pymel103 = Path('%s/python/maya/pymel-1.0.3' % _pNetworkLoc)

        for _dir in pymel103.dirs():
            if "pymel" not in _dir.basename() and "maya" not in _dir.basename(
            ):  #keep 'pymel' & 'maya'!
                print "Cleaning unneeded: %s/." % _dir
                # make writable
                for _file in _dir.walk():
                    _file.makeWritable()

                if _dir.exists():
                    try:
                        _dir.rmtree()
                        print "Removing dir: %s" % _dir
                    except WindowsError:
                        print "Unable to delete dir: '%s'" % _dir
                        raise

        # make writable
        for _file in pymel103.files():
            _file.makeWritable()
            _file.remove()


#		# clean
#		try:
#			Path('%s/.settings' % self.networkLoc).removedirs() # Fails. Read-Only?
#		except WindowsError:
#			print "Failed to remove %s/.settings'" % self.networkLoc

        print "**********************************"
        print "cleaning of '%s' complete." % _pNetworkLoc
        print "**********************************"
        logger.info("**********************************")
        logger.info("cleaning of '%s' complete." % _pNetworkLoc)
        logger.info("**********************************")
    def clean(self, pNetworkLoc=""):
        _pNetworkLoc = pNetworkLoc

        # clean pymel
        pymel102 = Path("%s/python/maya/pymel-1.0.2" % _pNetworkLoc)
        if pymel102.exists():
            print "Cleaning old: %s/." % _pNetworkLoc
            for _dir in pymel102.dirs():
                # make writable
                for _file in _dir.walk():
                    _file.makeWritable()

                if _dir.exists():
                    try:
                        _dir.rmtree()
                        print "Removing dir: %s" % _dir
                    except WindowsError:
                        print "Unable to delete dir: '%s'" % _dir
                        raise
                        # remote top dir too
            pymel102.rmtree()

        pymel103 = Path("%s/python/maya/pymel-1.0.3" % _pNetworkLoc)

        for _dir in pymel103.dirs():
            if "pymel" not in _dir.basename() and "maya" not in _dir.basename():  # keep 'pymel' & 'maya'!
                print "Cleaning unneeded: %s/." % _dir
                # make writable
                for _file in _dir.walk():
                    _file.makeWritable()

                if _dir.exists():
                    try:
                        _dir.rmtree()
                        print "Removing dir: %s" % _dir
                    except WindowsError:
                        print "Unable to delete dir: '%s'" % _dir
                        raise

                        # make writable
        for _file in pymel103.files():
            _file.makeWritable()
            _file.remove()

        # 		# clean
        # 		try:
        # 			Path('%s/.settings' % self.networkLoc).removedirs() # Fails. Read-Only?
        # 		except WindowsError:
        # 			print "Failed to remove %s/.settings'" % self.networkLoc

        print "**********************************"
        print "cleaning of '%s' complete." % _pNetworkLoc
        print "**********************************"
        logger.info("**********************************")
        logger.info("cleaning of '%s' complete." % _pNetworkLoc)
        logger.info("**********************************")
    def pushToNetwork(self, networkLoc=gv.toolsLocation, remote=True):
        """ copies all files from depot to desired
			network test location
			Params:
				networkLoc: destination location
			Returns: True/False?
		"""

        _pNetworkLoc = Path(networkLoc)
        result = True

        # copy to remote build location, straight-up delete and copy all
        if remote:

            # try whole loop 5 times?
            for unused in range(4):
                if _pNetworkLoc.exists():
                    # nuke current folders
                    print "Cleaning old: %s/." % _pNetworkLoc
                    for _dir in _pNetworkLoc.dirs():
                        # make writable
                        for _file in _dir.walk():
                            _file.makeWritable()

                            # try /python twice
                        if "python" in _dir:
                            try:
                                _dir.rmtree()
                                print "Removing dir: %s" % _dir
                            except WindowsError:
                                print "Failed once on '%s', trying again . . ." % _dir

                        if _dir.exists():
                            try:
                                _dir.rmtree()
                                print "Removing dir: %s" % _dir
                            except WindowsError:
                                print "Unable to delete dir: '%s'" % _dir
                                raise
                                # remote top dir too
                    _pNetworkLoc.rmtree()

                    # copy to network
            print "Copying '%s' dir to '%s'" % (self.pipelineSourceLocation, _pNetworkLoc)
            try:
                Path(self.pipelineSourceLocation).copytree(_pNetworkLoc)
            except WindowsError:
                print "Process locked trying to copy to: '%s'. Please just run again." % _pNetworkLoc
                raise
            except shutil.Error as e:
                print "Permission denied for file/folder: '%s'" % e[0]

                # success?
            if not _pNetworkLoc.exists():
                logger.error("Failed to copy to remote location build: '%s'" % _pNetworkLoc)

                # copy/move dataResources sub-folder
            for _dir in Path("%s/dataResources" % _pNetworkLoc).dirs():
                if _dir.namebase == "installData":
                    Path(_dir).move(_pNetworkLoc)

                    # have to dance around data and installData dirs
        else:
            if _pNetworkLoc.exists():
                # nuke current folders
                print "Cleaning old: %s/." % _pNetworkLoc
                for _dir in _pNetworkLoc.dirs():
                    if "data" not in _dir:  # keep 'data' & 'installData'!
                        # make writable
                        for _file in _dir.walk():
                            _file.makeWritable()

                            # try /python twice
                        if "python" in _dir:
                            try:
                                _dir.rmtree()
                            except WindowsError:
                                print "Failed once on '%s', trying again . . ." % _dir

                        if _dir.exists():
                            try:
                                _dir.rmtree()
                                print "Removing dir: %s" % _dir
                            except WindowsError:
                                print "Unable to delete dir: '%s'" % _dir
                                raise

                                # clean dataResources
                    elif _dir == "dataResources":
                        # make writable
                        for _file in _dir.walk():
                            _file.makeWritable()
                        print "Removing dir: %s" % _dir
                        _dir.rmtree()

                        # copy to network
            tempNetworkLoc = Path("%s/temp" % _pNetworkLoc)

            # copy
            print "Copying '%s' dir to '%s'" % (self.pipelineSourceLocation, tempNetworkLoc)
            try:
                Path(self.pipelineSourceLocation).copytree(tempNetworkLoc)
            except WindowsError:
                print "Process locked trying to copy to: '%s'. Please just run again." % tempNetworkLoc
            except shutil.Error as e:
                print "Permission denied for file/folder: '%s'" % e[0]

                # move first-layer sub-dirs from '/temp' up to parent
            for _dir in tempNetworkLoc.dirs():
                try:
                    if "data" not in _dir:  # skip 'data' & 'installData'!
                        Path(_dir).move(_pNetworkLoc)
                except WindowsError:
                    print "failed on: " + _dir
                except shutil.Error:
                    print "failed to copy from dir: '%s', already exists?" % _dir
                    raise

                    # nuke tempNetworkLoc
            if tempNetworkLoc.exists():
                print "Cleaning old: %s" % tempNetworkLoc
                # make writable
                for _file in tempNetworkLoc.walk():
                    _file.makeWritable()
                print "Removing tree: %s" % tempNetworkLoc
                tempNetworkLoc.rmtree()

                ############# start cleaning ##############

                # clean un-needed root folders
        unNeededRoot = ["dataResources", "docs", "logs"]
        for unNeeded in unNeededRoot:
            print "Cleaning un-needed: %s/%s" % (_pNetworkLoc, unNeeded)
            for _dir in Path(_pNetworkLoc).dirs():
                if _dir.namebase == unNeeded:
                    # make writable
                    for _file in _dir.walk():
                        _file.makeWritable()
                    print "Removing dir: %s" % _dir
                    _dir.rmtree()

                    # clean unitTests
        print "Cleaning un-needed: %s/python/unitTests" % _pNetworkLoc
        for _dir in Path("%s/python" % _pNetworkLoc).dirs():
            if _dir.namebase == "unitTests":
                # make writable
                for _file in _dir.walk():
                    _file.makeWritable()
                print "Removing dir: %s" % _dir
                _dir.rmtree()

                # clean non-maya/pymel dirs from pymels
        print "Cleaning un-needed: %s/python/maya/pymel" % _pNetworkLoc
        pyMelDirs = ["pymel-1.0.2", "pymel-1.0.3"]
        for pyMelDir in pyMelDirs:
            if not Path("%s/python/maya/%s" % (_pNetworkLoc, pyMelDir)).exists():
                logger.error("No pymel dir found, probably failed copy earlier.")
                if not _dir.namebase == "maya" and not _dir.namebase == "pymel":
                    # make writable
                    for _file in _dir.walk():
                        _file.makeWritable()
                    print "Removing dir: %s" % _dir
                    _dir.rmtree()
                for _file in Path("%s/python/maya/%s" % (_pNetworkLoc, pyMelDir)).files():
                    _file.makeWritable()
                    print "Removing file: %s" % _file
                    _file.remove()

                    # clean apps
        print "Cleaning un-needed: %s/python/apps" % _pNetworkLoc
        for _dir in Path("%s/python/apps" % _pNetworkLoc).dirs():
            if not _dir.namebase == "APE":
                # make writable
                for _file in _dir.walk():
                    _file.makeWritable()
                print "Removing dir: %s" % _dir
                _dir.rmtree()

                # clean misc
        print "Cleaning un-needed project files in : %s" % _pNetworkLoc
        unNeededRoot = [".project", ".pydevproject", "artMonkey.wpr", "artMonkey.wpu"]
        for unNeeded in unNeededRoot:
            for _file in _pNetworkLoc.files():
                if _file.basename() == unNeeded:
                    # make writable
                    _file.makeWritable()
                    print "Removing file: %s" % _file
                    _file.remove()

        print "**********************************"
        print "Push To Network complete."
        print "**********************************"
        logger.info("**********************************")
        logger.info("Push To Network complete.")
        logger.info("**********************************")

        return result
    def pushToNetwork(self, networkLoc=gv.toolsLocation, remote=True):
        ''' copies all files from depot to desired
			network test location
			Params:
				networkLoc: destination location
			Returns: True/False?
		'''

        _pNetworkLoc = Path(networkLoc)
        result = True

        # copy to remote build location, straight-up delete and copy all
        if remote:

            # try whole loop 5 times?
            for unused in range(4):
                if _pNetworkLoc.exists():
                    # nuke current folders
                    print "Cleaning old: %s/." % _pNetworkLoc
                    for _dir in _pNetworkLoc.dirs():
                        # make writable
                        for _file in _dir.walk():
                            _file.makeWritable()

                        # try /python twice
                        if 'python' in _dir:
                            try:
                                _dir.rmtree()
                                print "Removing dir: %s" % _dir
                            except WindowsError:
                                print "Failed once on '%s', trying again . . ." % _dir

                        if _dir.exists():
                            try:
                                _dir.rmtree()
                                print "Removing dir: %s" % _dir
                            except WindowsError:
                                print "Unable to delete dir: '%s'" % _dir
                                raise
                    # remote top dir too
                    _pNetworkLoc.rmtree()

            # copy to network
            print "Copying '%s' dir to '%s'" % (self.pipelineSourceLocation,
                                                _pNetworkLoc)
            try:
                Path(self.pipelineSourceLocation).copytree(_pNetworkLoc)
            except WindowsError:
                print "Process locked trying to copy to: '%s'. Please just run again." % _pNetworkLoc
                raise
            except shutil.Error as e:
                print "Permission denied for file/folder: '%s'" % e[0]

            # success?
            if not _pNetworkLoc.exists():
                logger.error("Failed to copy to remote location build: '%s'" %
                             _pNetworkLoc)

            # copy/move dataResources sub-folder
            for _dir in Path('%s/dataResources' % _pNetworkLoc).dirs():
                if _dir.namebase == 'installData':
                    Path(_dir).move(_pNetworkLoc)

        # have to dance around data and installData dirs
        else:
            if _pNetworkLoc.exists():
                # nuke current folders
                print "Cleaning old: %s/." % _pNetworkLoc
                for _dir in _pNetworkLoc.dirs():
                    if "data" not in _dir:  #keep 'data' & 'installData'!
                        # make writable
                        for _file in _dir.walk():
                            _file.makeWritable()

                        # try /python twice
                        if 'python' in _dir:
                            try:
                                _dir.rmtree()
                            except WindowsError:
                                print "Failed once on '%s', trying again . . ." % _dir

                        if _dir.exists():
                            try:
                                _dir.rmtree()
                                print "Removing dir: %s" % _dir
                            except WindowsError:
                                print "Unable to delete dir: '%s'" % _dir
                                raise

                    # clean dataResources
                    elif _dir == 'dataResources':
                        # make writable
                        for _file in _dir.walk():
                            _file.makeWritable()
                        print "Removing dir: %s" % _dir
                        _dir.rmtree()

            # copy to network
            tempNetworkLoc = Path('%s/temp' % _pNetworkLoc)

            # copy
            print "Copying '%s' dir to '%s'" % (self.pipelineSourceLocation,
                                                tempNetworkLoc)
            try:
                Path(self.pipelineSourceLocation).copytree(tempNetworkLoc)
            except WindowsError:
                print "Process locked trying to copy to: '%s'. Please just run again." % tempNetworkLoc
            except shutil.Error as e:
                print "Permission denied for file/folder: '%s'" % e[0]

            # move first-layer sub-dirs from '/temp' up to parent
            for _dir in tempNetworkLoc.dirs():
                try:
                    if "data" not in _dir:  #skip 'data' & 'installData'!
                        Path(_dir).move(_pNetworkLoc)
                except WindowsError:
                    print "failed on: " + _dir
                except shutil.Error:
                    print "failed to copy from dir: '%s', already exists?" % _dir
                    raise

            # nuke tempNetworkLoc
            if tempNetworkLoc.exists():
                print "Cleaning old: %s" % tempNetworkLoc
                # make writable
                for _file in tempNetworkLoc.walk():
                    _file.makeWritable()
                print "Removing tree: %s" % tempNetworkLoc
                tempNetworkLoc.rmtree()

        ############# start cleaning ##############

        # clean un-needed root folders
        unNeededRoot = ['dataResources', 'docs', 'logs']
        for unNeeded in unNeededRoot:
            print "Cleaning un-needed: %s/%s" % (_pNetworkLoc, unNeeded)
            for _dir in Path(_pNetworkLoc).dirs():
                if _dir.namebase == unNeeded:
                    # make writable
                    for _file in _dir.walk():
                        _file.makeWritable()
                    print "Removing dir: %s" % _dir
                    _dir.rmtree()

        # clean unitTests
        print "Cleaning un-needed: %s/python/unitTests" % _pNetworkLoc
        for _dir in Path('%s/python' % _pNetworkLoc).dirs():
            if _dir.namebase == 'unitTests':
                # make writable
                for _file in _dir.walk():
                    _file.makeWritable()
                print "Removing dir: %s" % _dir
                _dir.rmtree()

        # clean non-maya/pymel dirs from pymels
        print "Cleaning un-needed: %s/python/maya/pymel" % _pNetworkLoc
        pyMelDirs = ['pymel-1.0.2', 'pymel-1.0.3']
        for pyMelDir in pyMelDirs:
            if not Path('%s/python/maya/%s' %
                        (_pNetworkLoc, pyMelDir)).exists():
                logger.error(
                    "No pymel dir found, probably failed copy earlier.")
                if not _dir.namebase == 'maya' and not _dir.namebase == 'pymel':
                    # make writable
                    for _file in _dir.walk():
                        _file.makeWritable()
                    print "Removing dir: %s" % _dir
                    _dir.rmtree()
                for _file in Path('%s/python/maya/%s' %
                                  (_pNetworkLoc, pyMelDir)).files():
                    _file.makeWritable()
                    print "Removing file: %s" % _file
                    _file.remove()

        # clean apps
        print "Cleaning un-needed: %s/python/apps" % _pNetworkLoc
        for _dir in Path('%s/python/apps' % _pNetworkLoc).dirs():
            if not _dir.namebase == 'APE':
                # make writable
                for _file in _dir.walk():
                    _file.makeWritable()
                print "Removing dir: %s" % _dir
                _dir.rmtree()

        # clean misc
        print "Cleaning un-needed project files in : %s" % _pNetworkLoc
        unNeededRoot = [
            '.project', '.pydevproject', 'artMonkey.wpr', 'artMonkey.wpu'
        ]
        for unNeeded in unNeededRoot:
            for _file in _pNetworkLoc.files():
                if _file.basename() == unNeeded:
                    # make writable
                    _file.makeWritable()
                    print "Removing file: %s" % _file
                    _file.remove()

        print "**********************************"
        print "Push To Network complete."
        print "**********************************"
        logger.info("**********************************")
        logger.info("Push To Network complete.")
        logger.info("**********************************")

        return result