~ubuntu-branches/ubuntu/saucy/migrate/saucy-proposed

« back to all changes in this revision

Viewing changes to migrate/versioning/migrate_repository.py

  • Committer: Bazaar Package Importer
  • Author(s): Jan Dittberner
  • Date: 2010-07-12 00:24:57 UTC
  • mfrom: (1.1.5 upstream) (2.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100712002457-4j2fdmco4u9kqzm5
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
import os
8
8
import sys
 
9
import logging
 
10
 
 
11
log = logging.getLogger(__name__)
9
12
 
10
13
 
11
14
def usage():
22
25
 
23
26
def delete_file(filepath):
24
27
    """Deletes a file and prints a message."""
25
 
    print '    Deleting file: %s' % filepath
 
28
    log.info('Deleting file: %s' % filepath)
26
29
    os.remove(filepath)
27
30
 
28
31
 
29
32
def move_file(src, tgt):
30
33
    """Moves a file and prints a message."""
31
 
    print '    Moving file %s to %s' % (src, tgt)
 
34
    log.info('Moving file %s to %s' % (src, tgt))
32
35
    if os.path.exists(tgt):
33
36
        raise Exception(
34
37
            'Cannot move file %s because target %s already exists' % \
38
41
 
39
42
def delete_directory(dirpath):
40
43
    """Delete a directory and print a message."""
41
 
    print '    Deleting directory: %s' % dirpath
 
44
    log.info('Deleting directory: %s' % dirpath)
42
45
    os.rmdir(dirpath)
43
46
 
44
47
 
45
48
def migrate_repository(repos):
46
49
    """Does the actual migration to the new repository format."""
47
 
    print 'Migrating repository at: %s to new format' % repos
 
50
    log.info('Migrating repository at: %s to new format' % repos)
48
51
    versions = '%s/versions' % repos
49
52
    dirs = os.listdir(versions)
50
53
    # Only use int's in list.
52
55
    numdirs.sort()  # Sort list.
53
56
    for dirname in numdirs:
54
57
        origdir = '%s/%s' % (versions, dirname)
55
 
        print '  Working on directory: %s' % origdir
 
58
        log.info('Working on directory: %s' % origdir)
56
59
        files = os.listdir(origdir)
57
60
        files.sort()
58
61
        for filename in files: