Revision e2a0abb8

b/ci/snf-ci
1 1
#!/usr/bin/env python
2 2

  
3
# Invalid name for type module. pylint: disable-msg=C0103
4

  
3 5
"""
6
Continuous Integration script for Synnefo.
4 7
"""
8

  
5 9
import os
6 10
from utils import SynnefoCI
7 11
from optparse import OptionParser
......
45 49
             ALL_CMDS])
46 50

  
47 51

  
48
def main():
52
def main():  # Too many branches. pylint: disable-msg=R0912
53
    """Parse command line options and run the specified actions"""
49 54
    parser = OptionParser(usage=USAGE)
50 55
    parser.add_option("--conf", dest="config_file", default=None,
51
                      help="Configuration file for SynnefoCI script"),
56
                      help="Configuration file for SynnefoCI script")
52 57
    parser.add_option("-c", "--cloud", dest="kamaki_cloud", default=None,
53
                      help="Use specified cloud, as is in .kamakirc"),
58
                      help="Use specified cloud, as is in .kamakirc")
54 59
    parser.add_option("-f", "--flavor", dest="flavor", default=None,
55 60
                      help="Name of flavor to use for the server.")
56 61
    parser.add_option("-i", "--image", dest="image", default=None,
b/ci/utils.py
27 27
        args = ('running',)
28 28
    else:
29 29
        args = ('running', 'stdout',)
30
    with fabric.hide(*args):
30
    with fabric.hide(*args):  # Used * or ** magic. pylint: disable-msg=W0142
31 31
        return fabric.run(cmd)
32 32

  
33 33

  
......
118 118
        if cleanup_config:
119 119
            try:
120 120
                os.remove(temp_config)
121
            except:
121
            except OSError:
122 122
                pass
123 123
        else:
124 124
            self.config.read(self.config.get('Global', 'temporary_config'))
......
281 281

  
282 282
    @_check_fabric
283 283
    def _copy_ssh_keys(self):
284
        """Upload/Install ssh keys to server"""
284 285
        if not self.config.has_option("Deployment", "ssh_keys"):
285 286
            return
286 287
        authorized_keys = self.config.get("Deployment",
......
356 357
        synnefo_repo = self.config.get('Global', 'synnefo_repo')
357 358
        synnefo_branch = self.config.get("Global", "synnefo_branch")
358 359
        if synnefo_branch == "":
359
            synnefo_branch =\
360
                subprocess.Popen(["git", "rev-parse", "--abbrev-ref", "HEAD"],
360
            synnefo_branch = \
361
                subprocess.Popen(
362
                    ["git", "rev-parse", "--abbrev-ref", "HEAD"],
361 363
                    stdout=subprocess.PIPE).communicate()[0].strip()
362 364
            if synnefo_branch == "HEAD":
363 365
                synnefo_branch = \
364
                    subprocess.Popen(["git", "rev-parse","--short", "HEAD"],
366
                    subprocess.Popen(
367
                        ["git", "rev-parse", "--short", "HEAD"],
365 368
                        stdout=subprocess.PIPE).communicate()[0].strip()
366 369
        self.logger.info("Will use branch %s" % synnefo_branch)
367 370
        # Currently clonning synnefo can fail unexpectedly
......
372 375
                _run("git clone %s synnefo" % synnefo_repo, False)
373 376
                cloned = True
374 377
                break
375
            except:
378
            except BaseException:
376 379
                self.logger.warning("Clonning synnefo failed.. retrying %s"
377 380
                                    % i)
378
        cmd ="""
381
        cmd = """
379 382
        cd synnefo
380
        for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
383
        for branch in `git branch -a | grep remotes | \
384
                       grep -v HEAD | grep -v master`; do
381 385
            git branch --track ${branch##*/} $branch
382 386
        done
383 387
        git checkout %s
......
446 450
        """
447 451
        _run(cmd, False)
448 452

  
449

  
450 453
    @_check_fabric
451 454
    def build_documentation(self):
455
        """Build Synnefo documentation"""
452 456
        self.logger.info("Build Synnefo documentation..")
453 457
        _run("pip install -U Sphinx", False)
454 458
        with fabric.cd("synnefo"):
455
            _run("devflow-update-version; ./ci/make_docs.sh synnefo_documentation", False)
459
            _run("devflow-update-version; "
460
                 "./ci/make_docs.sh synnefo_documentation", False)
456 461

  
457 462
    def fetch_documentation(self, dest=None):
463
        """Fetch Synnefo documentation"""
464
        self.logger.info("Fetch Synnefo documentation..")
458 465
        if dest is None:
459 466
            dest = "synnefo_documentation"
460 467
        dest = os.path.abspath(dest)
......
540 547

  
541 548
    @_check_fabric
542 549
    def fetch_compressed(self, src, dest=None):
550
        """Create a tarball and fetch it locally"""
543 551
        self.logger.debug("Creating tarball of %s" % src)
544 552
        basename = os.path.basename(src)
545 553
        tar_file = basename + ".tgz"
......
566 574

  
567 575
    @_check_fabric
568 576
    def fetch_packages(self, dest=None):
577
        """Fetch Synnefo packages"""
569 578
        if dest is None:
570 579
            dest = self.config.get('Global', 'pkgs_dir')
571 580
        dest = os.path.abspath(dest)

Also available in: Unified diff