Package dak :: Module export
[hide private]
[frames] | no frames]

Source Code for Module dak.export

 1  #! /usr/bin/env python3 
 2  # 
 3  # Copyright (C) 2012, Ansgar Burchardt <ansgar@debian.org> 
 4  # 
 5  # This program is free software; you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation; either version 2 of the License, or 
 8  # (at your option) any later version. 
 9  # 
10  # This program is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License along 
16  # with this program; if not, write to the Free Software Foundation, Inc., 
17  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
18   
19  import apt_pkg 
20  import sys 
21   
22  from daklib.config import Config 
23  from daklib.dbconn import * 
24  from daklib.policy import UploadCopy 
25   
26   
27 -def usage():
28 print("""Usage: dak export -q <queue> [options] -a|--all|<source...> 29 30 Export uploads from policy queues, that is the changes files for the given 31 source package and all other files associated with that. 32 33 -a --all export all uploads 34 -c --copy copy files instead of symlinking them 35 -d <directory> target directory to export packages to 36 default: current directory 37 -q <queue> queue to grab uploads from 38 <source> source package name to export 39 """)
40 41
42 -def main(argv=None):
43 if argv is None: 44 argv = sys.argv 45 46 arguments = [('h', 'help', 'Export::Options::Help'), 47 ('a', 'all', 'Export::Options::All'), 48 ('c', 'copy', 'Export::Options::Copy'), 49 ('d', 'directory', 'Export::Options::Directory', 'HasArg'), 50 ('q', 'queue', 'Export::Options::Queue', 'HasArg')] 51 52 cnf = Config() 53 source_names = apt_pkg.parse_commandline(cnf.Cnf, arguments, argv) 54 options = cnf.subtree('Export::Options') 55 56 if 'Help' in options or 'Queue' not in options: 57 usage() 58 sys.exit(0) 59 60 session = DBConn().session() 61 62 queue = session.query(PolicyQueue).filter_by(queue_name=options['Queue']).first() 63 if queue is None: 64 print("Unknown queue '{0}'".format(options['Queue'])) 65 sys.exit(1) 66 uploads = session.query(PolicyQueueUpload).filter_by(policy_queue=queue) 67 if 'All' not in options: 68 uploads = uploads.filter(DBChange.source.in_(source_names)) 69 directory = options.get('Directory', '.') 70 symlink = 'Copy' not in options 71 72 for u in uploads: 73 UploadCopy(u).export(directory, symlink=symlink, ignore_existing=True)
74 75 76 if __name__ == '__main__': 77 main() 78