コード例 #1
0
ファイル: fileutils.py プロジェクト: apetrone/pegasus
	def commandline(self):
		self._params = ['src', 'dst']
		src = Path.normalized(getattr(self, 'src', None))
		dst = Path.normalized(getattr(self, 'dst', None))
		is_directory = getattr(self, 'is_directory', False)

		return HostPlatform.instance.copy_command(src, dst, is_directory=is_directory)
コード例 #2
0
ファイル: fileutils.py プロジェクト: apetrone/pegasus
	def commandline(self):
		self._params = ['path']
		path = Path.normalized( getattr(self, "path", None))

		cwd = get_working_directory()
		newpath = Path.absolute(os.path.join(cwd, path))

		push_working_directory(newpath)
		#logging.info("current directory: \"%s\"" % cwd)
		#logging.info("push_directory: %s" % newpath)
		return None
コード例 #3
0
ファイル: core.py プロジェクト: apetrone/pegasus
	def startup():
		# setup the environment
		Core.set_install_path()

		# initialize logging
		Core.init_logging(None)

		# load the config file
		Core.load_config("config.json")

		Path.set_hostplatform(HostPlatform)

		Attributes.load_attributes(Core.config)
コード例 #4
0
ファイル: fileutils.py プロジェクト: apetrone/pegasus
	def run(self):
		path = Path.normalized(getattr(self, 'path', None))
		is_directory = getattr(self, 'is_directory', False)

		# don't execute anything if the path doesn't exist on the local filesystem.
		if (is_directory and os.path.isdir(path)) or os.path.exists(path):
			return super(Delete, self).run()
		else:
			return ""
コード例 #5
0
ファイル: fileutils.py プロジェクト: apetrone/pegasus
	def run(self):
		src = Path.normalized(getattr(self, 'src', None))
		dst = Path.normalized(getattr(self, 'dst', None))

		md = Makedirs( path=dst )
		md.run()

		try:
			for path in glob.iglob( src ):
				if os.path.isdir( path ):
					#logging.info("Need to handle directory copy: %s -> %s" % (path, dst))
					shutil.copytree( path, os.path.join(dst, os.path.basename(path)), symlinks=True )
				else:
					#logging.info("Copying file: %s" % path)
					shutil.copy( path, dst )
		except OSError as e:
			import errno
			if e.errno == errno.EEXIST:
				pass
		except:
			raise

		return True
コード例 #6
0
ファイル: fileutils.py プロジェクト: apetrone/pegasus
	def run(self):
		path = Path.normalized( getattr(self, 'path', None))
		if path:
			try:
				path = Path.absolute(os.path.join(get_working_directory(), path))

				# if this path already exists; return False as it wasn't
				# created by this method.
				if os.path.isdir(path):
					return False

				#logging.info( "MAKEDIRS: %s" % path )
				os.makedirs(path)
			except OSError as exc:
				if exc.errno == 20:
					logging.error("Attempted to make a path: \"%s\", but ran into a file with the name of an expected directory." % path)
					logging.error("Check for files that have the same name of the directory you may want to create.")
					raise

				# OSError: [Errno 17] File exists:
				pass
			except:
				raise
		return True
コード例 #7
0
ファイル: fileutils.py プロジェクト: apetrone/pegasus
	def commandline(self):
		self._params = ['path']
		path = Path.normalized(getattr(self, 'path', None))
		is_directory = getattr(self, 'is_directory', False)
		return HostPlatform.instance.delete_command(path, is_directory=is_directory)