summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-02-14 01:14:47 -0600
committerJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-02-14 01:14:47 -0600
commit2321a53d35a9736b8c5c715ca40a9af69b1bf64e (patch)
tree6b7e89a94be6a0b8e839fb49fb3a989af4508f85
parent6a37d25e51228a0a83d004b9acda63c528972a26 (diff)
Rearranged functions
-rw-r--r--config.py5
-rw-r--r--filter.py43
-rw-r--r--pato2.py40
3 files changed, 45 insertions, 43 deletions
diff --git a/config.py b/config.py
index bd8ef1b..4854e0d 100644
--- a/config.py
+++ b/config.py
@@ -40,6 +40,11 @@ whitelist = docs + "/whitelist.txt"
pending = docs + "/pending"
rsync_blacklist = docs + "/rsyncBlacklist"
+# Rsync commands
+
+rsync_list_command="rsync -a --no-motd --list-only "
+
+
# Classes and Exceptions
class NonValidFile(ValueError): pass
class NonValidDir(ValueError): pass
diff --git a/filter.py b/filter.py
index ffc0965..b51dba8 100644
--- a/filter.py
+++ b/filter.py
@@ -6,49 +6,6 @@ import re
from repm.config import *
from repm.pato2 import *
-rsync_list_command="rsync -a --no-motd --list-only "
-
-def generate_rsync_command(base_command, dir_list, destdir=repodir, mirror_name=mirror,
- mirror_path=mirrorpath, blacklist_file=False):
- """ Generates an rsync command for executing it by combining all parameters.
-
- Parameters:
- ----------
- base_command -> str
- mirror_name -> str
- mirror_path -> str
- dir_list -> list or tuple
- destdir -> str Path to dir, dir must exist.
- blacklist_file -> False or str Path to file, file must exist.
-
- Return:
- ----------
- rsync_command -> str """
- from os.path import isfile, isdir
-
- if blacklist_file and not isfile(blacklist_file):
- print(blacklist_file + " is not a file")
- raise NonValidFile
-
- if not os.path.isdir(destdir):
- print(destdir + " is not a directory")
- raise NonValidDir
-
- dir_list="{" + ",".join(dir_list) + "}"
-
- if blacklist_file:
- return " ".join((base_command, "--exclude-from-file="+blacklist_file,
- mirror_name + mirror_path + dir_list, destdir))
- return " ".join((base_command, mirror_name + mirror_path + dir_list, destdir))
-
-def run_rsync(base_for_rsync=rsync_list_command, dir_list_for_rsync=(repo_list + dir_list),
- debug=verbose):
- """ Runs rsync and gets returns it's output """
- cmd = str(generate_rsync_command(rsync_list_command, (repo_list + dir_list)))
- if debug:
- printf("rsync_command" + cmd)
- return commands.getoutput(cmd)
-
def get_file_list_from_rsync_output(rsync_output):
""" Generates a list of packages and versions from an rsync output using --list-only --no-motd.
diff --git a/pato2.py b/pato2.py
index cfdd859..125ae8c 100644
--- a/pato2.py
+++ b/pato2.py
@@ -166,6 +166,46 @@ def get_licenses(verbose_=verbose):
a=commands.getoutput(cmd_)
if verbose_: printf(a)
+def generate_rsync_command(base_command, dir_list, destdir=repodir,
+ source=mirror+mirrorpath, blacklist_file=False):
+ """ Generates an rsync command for executing it by combining all parameters.
+
+ Parameters:
+ ----------
+ base_command -> str
+ dir_list -> list or tuple
+ destdir -> str Path to dir, dir must exist.
+ source -> str The source for rsync
+ blacklist_file -> False or str Path to file, file must exist.
+
+ Return:
+ ----------
+ rsync_command -> str """
+ from os.path import isfile, isdir
+
+ if blacklist_file and not isfile(blacklist_file):
+ print(blacklist_file + " is not a file")
+ raise NonValidFile
+
+ if not os.path.isdir(destdir):
+ print(destdir + " is not a directory")
+ raise NonValidDir
+
+ dir_list="{" + ",".join(dir_list) + "}"
+
+ if blacklist_file:
+ return " ".join((base_command, "--exclude-from-file="+blacklist_file,
+ mirror_name + mirror_path + dir_list, destdir))
+ return " ".join((base_command, mirror_name + mirror_path + dir_list, destdir))
+
+def run_rsync(base_for_rsync=rsync_list_command, dir_list_for_rsync=(repo_list + dir_list),
+ debug=verbose):
+ """ Runs rsync and gets returns it's output """
+ cmd = str(generate_rsync_command(rsync_list_command, (repo_list + dir_list)))
+ if debug:
+ printf("rsync_command" + cmd)
+ return commands.getoutput(cmd)
+
if __name__ == "__main__":
from time import time
start_time = time()