Пример #1
0
	def run(self):
		config_file = self.read_file(self.CONFIG_PATH.path)

		dest_filename = Path(Settings.SOURCE_PATH + os.path.sep + config_file[0])
		print "Destination is %s" % dest_filename.path

		other_files = config_file[1:]

		dest_file_contents = []

		for line in other_files:
			firstCharacter = line[:1]

			if firstCharacter == "+":
				path = Path(Settings.SOURCE_PATH + os.path.sep + line[1:])

				if path.exists():
					print "Adding '%s'" % path.path
					dest_file_contents += self.read_file(path.path) + ["\n"]
				else:
					print "can not append file '%s'" % path.path

			else:
				path = Path(Settings.SOURCE_PATH + os.path.sep + line)

				if path.exists():
					print "Minifying '%s'" % path.path
					dest_file_contents += self.run_compiler(path)

				else:
					print "File '%s' does not exist!" % path.path

		self.save_file(dest_filename, "".join(dest_file_contents))
Пример #2
0
    def clean(self):
        path = Path(Settings.TARGET_PATH)

        if path.exists():
            shutil.rmtree(path.path)
            print "Removed '%s'" % Settings.TARGET_PATH
        else:
            print "Nothing to clean"
Пример #3
0
class Copy:
	src = None
	dest = None

	RSYNC_OPTIONS = ["-a", "--progress", "--delete-during"]

	def __init__(self, src, dest):
		self.src = Path(src)
		self.dest = Path(dest)

		if self.src is None:
			raise Exception("Source path is empty.")

		if self.dest is None:
			raise Exception("Destination path is empty.")

		if self.dest.is_remote is True and self.src.is_remote is True:
			raise Exception("Both paths can not be remote paths!")

		if self.src.is_remote is False and self.dest.is_remote is False:
			self.doCopyLocal()

		if not self.src.is_remote and self.dest.is_remote:
			self.doCopyRemote()

	def doCopyLocal(self):

		if self.dest.exists():
			print "Removing original folder '" + self.dest.path + "'"
			self.dest.remove()

		if self.src.is_dir():
			os.mkdir(self.dest.path)

		print "Copying '" + self.src.path + "' to '" + self.dest.path
		Merge(self.src.path, self.dest.path)

	def doCopyRemote(self):
		options = ["rsync"] + self.RSYNC_OPTIONS[:]

		options.append('-e')

		if self.dest.scheme == "ftp":
			options.append('ftp')
		else:
			if self.dest.portNumber is not None:
				options.append('"ssh -p %s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"' % self.dest.portNumber)
			else:
				options.append('"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"')

		src_path = self.src.path
		if os.path.isdir(src_path):
			src_path += "/"

		options += [src_path, self.dest.get_sync_path()]

		Execute().run(options)
Пример #4
0
class Shell(BaseCommand):
	path = None

	def __init__(self, path):
		self.path = Path(path)

		self.run()

	def run(self):
		if self.path.scheme == "ssh":
			executable = self.find_executable("ssh")

			path = self.path.path

			if not self.path.is_absolute:
				path = "./" + path

			command = [executable]

			if self.path.portNumber is not None and self.path.portNumber != 22:
				command += ["-p", str(self.path.portNumber)]

			command += ["-o", "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=no"]

			command += [self.path.get_ssh_path(), path]

			Execute().run(command)
Пример #5
0
	def __init__(self, src, dest):
		self.src = Path(src)
		self.dest = Path(dest)

		if self.src is None:
			raise Exception("Source path is empty.")

		if self.dest is None:
			raise Exception("Destination path is empty.")

		if self.dest.is_remote is True and self.src.is_remote is True:
			raise Exception("Both paths can not be remote paths!")

		if self.src.is_remote is False and self.dest.is_remote is False:
			self.doCopyLocal()

		if not self.src.is_remote and self.dest.is_remote:
			self.doCopyRemote()
Пример #6
0
	def __init__(self, path):
		self.path = Path(path)

		self.run()