[copr] master: Refactor the messages from manage.py (cbaa66e)
bkabrda at fedoraproject.org
bkabrda at fedoraproject.org
Tue Jan 15 11:07:00 UTC 2013
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit cbaa66e69a5d69edcd66768d0b78ff5c2ba65e1c
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date: Tue Jan 15 12:02:57 2013 +0100
Refactor the messages from manage.py
>---------------------------------------------------------------
coprs_frontend/manage.py | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/coprs_frontend/manage.py b/coprs_frontend/manage.py
index be5a5b1..766ca46 100755
--- a/coprs_frontend/manage.py
+++ b/coprs_frontend/manage.py
@@ -43,6 +43,16 @@ class DropDBCommand(Command):
db.drop_all()
class ChrootCommand(Command):
+ def print_invalid_format(self, chroot_name):
+ print '{0} - invalid chroot format, must be "{release}-{version}-{arch}".'.format(chroot_name)
+
+ def print_already_exists(self, chroot_name):
+ print '{0} - already exists.'.format(chroot_name)
+
+ def print_doesnt_exist(self, chroot_name):
+ print '{0} - chroot doesn\'t exist.'.format(chroot_name)
+
+
option_list = (
Option('chroot_names',
help='Chroot name, e.g. fedora-18-x86_64.',
@@ -55,9 +65,9 @@ class CreateChrootCommand(ChrootCommand):
for chroot_name in chroot_names:
split_chroot = chroot_name.split('-')
if len(split_chroot) < 3:
- print '{0} - Invalid chroot format, must be "{release}-{version}-{arch}".'.format(chroot_name)
+ self.print_invalid_format(chroot_name)
elif models.MockChroot.get(*split_chroot):
- print '{0} - already exists.'.format(chroot_name)
+ self.print_already_exists(chroot_name)
else:
new_chroot = models.MockChroot(os_release=split_chroot[0],
os_version=split_chroot[1],
@@ -72,10 +82,10 @@ class AlterChrootCommand(ChrootCommand):
for chroot_name in chroot_names:
split_chroot = chroot_name.split('-')
if len(split_chroot) < 3:
- print '{0} - invalid chroot format, must be "{release}-{version}-{arch}".'.format(chroot_name)
+ self.print_invalid_format(chroot_name)
chroot = models.MockChroot.get(*split_chroot)
if not chroot:
- print '{0} - chroot doesn\'t exist.'.format(chroot_name)
+ self.print_doesnt_exist(chroot_name)
else:
if action == 'activate':
chroot.is_active = True
@@ -100,10 +110,10 @@ class DropChrootCommand(ChrootCommand):
for chroot_name in chroot_names:
split_chroot = chroot_name.split('-')
if len(split_chroot) < 3:
- print '{0} - invalid chroot format, must be "{release}-{version}-{arch}".'.format(chroot_name)
+ self.print_invalid_format(chroot_name)
chroot = models.MockChroot.get(*split_chroot)
if not chroot:
- print '{0} - chroot doesn\'t exist.'.format(chroot_name)
+ self.print_doesnt_exist(chroot_name)
else:
db.session.delete(chroot)
db.session.commit()
More information about the copr-devel
mailing list