00001
00002
00003 from __future__ import with_statement
00004 PKG = 'job_generation'
00005 import roslib; roslib.load_manifest(PKG)
00006
00007 import sys
00008 import subprocess
00009 import rosdistro
00010 import optparse
00011 import datetime
00012 from job_generation.jobs_common import *
00013 from pysqlite2 import dbapi2 as sqlite
00014
00015
00016 def main():
00017 (options, args) = get_options(['rosdistro', 'overlay', 'variant'], ['database'])
00018 if not options:
00019 return -1
00020
00021
00022 distro_obj = rosdistro.Distro(get_rosdistro_file(options.rosdistro))
00023
00024
00025 if options.overlay == 'yes':
00026 rosinstall = rosdistro.variant_to_rosinstall(options.variant, distro_obj, 'release-tar')
00027 else:
00028 rosinstall = rosdistro.extended_variant_to_rosinstall(options.variant, distro_obj, 'release-tar')
00029
00030 print rosinstall
00031
00032
00033 if options.database:
00034 try:
00035 connection = sqlite.connect(options.database)
00036 cursor = connection.cursor()
00037 try:
00038 cursor.execute('CREATE TABLE rosinstall (stamp TIMESTAMP, rosdistro TEXT, variant TEXT, overlay TEXT)')
00039 except sqlite.OperationalError:
00040 pass
00041 cursor.execute('INSERT INTO rosinstall VALUES (?, ?, ?, ?)', (datetime.datetime.now(), options.rosdistro, options.variant, options.overlay))
00042 connection.commit()
00043 except:
00044 pass
00045
00046 if __name__ == '__main__':
00047 sys.exit(main())