def ext_check(self, verbose=False, autofix=False, interactive=False): rtcbins = [ rtc.strip() for rtc in self['manager.modules.preload'].split(',') if not len(rtc.strip()) == 0 ] valid_bins = [] for rtcbin in rtcbins: if not rtcbin.endswith(wasanbon.get_bin_file_ext()): if verbose or interactive: sys.stdout.write( ' - Detect invalid bin file expression (%s)\n' % rtcbin) valid_name = rtcbin[:rtcbin. rfind('.')] + wasanbon.get_bin_file_ext() if interactive or autofix: res = [] if autofix: res = 'yes' else: res = util.yes_no( ' - Change file name from %s to %s?' % (rtcbin, valid_name)) if res == 'yes': if verbose or interactive: sys.stdout.write(' - Changed.\n') valid_bins.append(valid_name) else: valid_bins.append(rtcbin) self['manager.modules.preload'] = '' for rtcbin in valid_bins: self.append('manager.modules.preload', rtcbin) pass
def delete(self, argv): self.parser.add_option( "-f", "--force", help="Force option (default=False)", default=False, action="store_true", dest="force_flag" ) self.parser.add_option("-u", "--user", help="set username", default=None, metavar="USER", dest="user") self.parser.add_option("-p", "--password", help="set password", default=None, metavar="PASSWD", dest="password") self.parser.add_option( "-s", "--service", help="set upstream service", default="github", metavar="SERVICE", dest="service" ) options, argv = self.parse_args(argv[:]) verbose = options.verbose_flag # This is default option force = options.force_flag service = options.service user, passwd = wasanbon.user_pass(user=options.user, passwd=options.password) sys.stdout.write("# Creating wasanbon binder in your %s\n" % service) repo_name = "wasanbon_binder" target_path = os.path.join(wasanbon.rtm_home(), "binder", user + owner_sign, repo_name + ".git") if service == "github": github = admin.github.Github(user, passwd) if github.exists_repo(repo_name): if not force: from wasanbon import util if util.yes_no("## Really delete?") == "no": sys.stdout.write("## Aborted.\n") return 0 github.delete_repo(repo_name) return 0 else: sys.stdout.write("# Unknown service name %s\n" % service) return -1 return 0
def ext_check(self, verbose=False, autofix=False, interactive=False): rtcbins = [rtc.strip() for rtc in self['manager.modules.preload'].split(',') if not len(rtc.strip()) == 0] valid_bins = [] for rtcbin in rtcbins: if not rtcbin.endswith(wasanbon.get_bin_file_ext()): if verbose or interactive: sys.stdout.write(' - Detect invalid bin file expression (%s)\n' % rtcbin) valid_name = rtcbin[:rtcbin.rfind('.')] + wasanbon.get_bin_file_ext() if interactive or autofix: res = [] if autofix: res = 'yes' else: res = util.yes_no(' - Change file name from %s to %s?' % (rtcbin, valid_name)) if res == 'yes': if verbose or interactive: sys.stdout.write(' - Changed.\n') valid_bins.append(valid_name) else: valid_bins.append(rtcbin) self['manager.modules.preload'] = '' for rtcbin in valid_bins: self.append('manager.modules.preload', rtcbin) pass
def select_conf(ans2): key = confs[ans2].name sys.stdout.write('## INPUT (%s):' % key) val = raw_input() if util.yes_no('# %s = %s. Okay?' % (key, val)) == 'yes': rtc.configuration_sets[active_conf_index].configuration_data[ans2].data = val return True return False
def select_conf(ans2): key = confs[ans2].name sys.stdout.write(' INPUT (%s):' % key) val = raw_input() if util.yes_no('%s = %s. Okay?' % (key, val)) == 'yes': admin.systembuilder.set_active_configuration_data(rtcs[ans], key, val) return True return False
def select_conf(ans2): key = confs[ans2].name sys.stdout.write(' INPUT (%s):' % key) val = raw_input() if util.yes_no('%s = %s. Okay?' % (key, val)) == 'yes': admin.systembuilder.set_active_configuration_data( rtcs[ans], key, val) return True return False
def select_conf(ans2): key = confs[ans2].name sys.stdout.write('## INPUT (%s):' % key) val = raw_input() if util.yes_no('# %s = %s. Okay?' % (key, val)) == 'yes': rtc.configuration_sets[ active_conf_index].configuration_data[ans2].data = val return True return False
def delete(self, argv): self.parser.add_option('-f', '--force', help='Force option (default=False)', default=False, action='store_true', dest='force_flag') self.parser.add_option('-u', '--user', help='set username', default=None, metavar='USER', dest='user') self.parser.add_option('-p', '--password', help='set password', default=None, metavar='PASSWD', dest='password') self.parser.add_option('-s', '--service', help='set upstream service', default='github', metavar='SERVICE', dest='service') options, argv = self.parse_args(argv[:]) verbose = options.verbose_flag # This is default option force = options.force_flag service = options.service user, passwd = wasanbon.user_pass(user=options.user, passwd=options.password) sys.stdout.write('# Creating wasanbon binder in your %s\n' % service) repo_name = 'wasanbon_binder' target_path = os.path.join(wasanbon.rtm_home(), 'binder', user + owner_sign, repo_name + '.git') if service == 'github': github = admin.github.Github(user, passwd) if github.exists_repo(repo_name): if not force: from wasanbon import util if util.yes_no('## Really delete?') == 'no': sys.stdout.write('## Aborted.\n') return 0 github.delete_repo(repo_name) return 0 else: sys.stdout.write('# Unknown service name %s\n' % service) return -1 return 0
def configure(self, args): """ Configure system interactively in console. $ mgr.py system configure """ self.parser.add_option('-f', '--file', help='Configure with Specific RTSProfile (must be placed in system_dir', default=None, dest='systemfile', action='store', type='string') options, argv = self.parse_args(args[:]) verbose = options.verbose_flag package = admin.package.get_package_from_path(os.getcwd()) if options.systemfile: filename = os.path.join(package.get_systempath(), options.systemfile) else: filename = package.default_system_filepath from rtsprofile.rts_profile import RtsProfile file = open(filename, 'r') rtsprofile = RtsProfile(xml_spec = file) del(file) rtc_names = [rtc.instance_name for rtc in rtsprofile.components] from wasanbon import util def select_rtc(ans): rtc = rtsprofile.components[ans] confs = [] active_conf_index = -1 if len(rtc.configuration_sets) != 0: for i, conf in enumerate(rtc.configuration_sets): if conf.id == rtc.active_configuration_set: active_conf_index = i confs = conf.configuration_data conf_names = [conf.name +':' + conf.data for conf in confs] def select_conf(ans2): key = confs[ans2].name sys.stdout.write('## INPUT (%s):' % key) val = raw_input() if util.yes_no('# %s = %s. Okay?' % (key, val)) == 'yes': rtc.configuration_sets[active_conf_index].configuration_data[ans2].data = val return True return False util.choice(conf_names, select_conf, msg='# Select Configuration') return False util.choice(rtc_names, select_rtc, msg='# Select RTC') if util.yes_no("Save System?") != 'yes': sys.stdout.write('# Aborted \n') return 0 while True: if util.no_yes('Rename Filename?') == 'yes': filepath = os.path.join(package.get_systempath(), raw_input('Filename:')) else: filepath = filename newfile = filepath + wasanbon.timestampstr() try: os.rename(filepath, newfile) except Exception, e: sys.stdout.write('## Exception occurred when renaming file.\n') traceback.print_exc() continue try: fout = open(filepath, 'w') fout.write(rtsprofile.save_to_xml()) fout.close() except: sys.stdout.write('## Exception occurred when saving file.\n') traceback.print_exc() continue break
def build(self, args): """ Build System in Console interactively $ mgr.py system build """ self.parser.add_option('-b', '--background', help='Launch in background(default=False)', default=False, action='store_true', dest='background_flag') self.parser.add_option('-w', '--wakeuptimeout', help='Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons', default=5, dest='wakeuptimeout', action='store', type='float') options, argv = self.parse_args(args[:]) verbose = options.verbose_flag background = options.background_flag wakeuptimeout = options.wakeuptimeout #force = options.force_flag package = admin.package.get_package_from_path(os.getcwd(), verbose=verbose) global endflag endflag = False try: processes = admin.systemlauncher.launch_system(package, verbose=verbose) time.sleep(wakeuptimeout) package = admin.package.get_package_from_path(os.getcwd()) nss = admin.nameserver.get_nameservers_from_package(package, verbose=verbose) for ns in nss: ns.refresh(verbose=verbose) # Interactive Connect pairs = admin.systemeditor.get_connectable_pairs(nss, verbose=verbose) from wasanbon import util for pair in pairs: if util.no_yes('# Connect? (%s->%s)\n' % (admin.systembuilder.get_port_full_path(pair[0]), admin.systembuilder.get_port_full_path(pair[1]))) == 'yes': while True: try: admin.systembuilder.connect_ports(pair[0], pair[1], verbose=verbose) sys.stdout.write('## Connected.\n') break except Exception, ex: if verbose: traceback.print_exc() pass sys.stdout.write('## Failed. \n') if util.yes_no('### Retry?') == 'no': break pass rtc_names = [] rtcs = [] for ns in nss: rtc_names = rtc_names + [admin.systembuilder.get_component_full_path(rtc) for rtc in ns.rtcs] rtcs = rtcs + ns.rtcs # Interactive Configure def select_rtc(ans): confs = admin.systemeditor.get_active_configuration_data(rtcs[ans]) conf_names = [conf.name +':' + conf.data for conf in confs] def select_conf(ans2): key = confs[ans2].name sys.stdout.write(' INPUT (%s):' % key) val = raw_input() if util.yes_no('%s = %s. Okay?' % (key, val)) == 'yes': admin.systembuilder.set_active_configuration_data(rtcs[ans], key, val) return True return False util.choice(conf_names, select_conf, msg='Select Configuration') return False util.choice(rtc_names, select_rtc, msg='Select RTC') #Save Running System if util.yes_no('# Save System ?') == 'yes': filename = os.path.basename(package.default_system_filepath) while True: if util.yes_no('# Rename filename? (default:%s)' % filename) == 'yes': while True: sys.stdout.write('# Input:') val = raw_input() if util.yes_no('# New Filename = %s. Okay?' % val) == 'yes': filename = val break pass pass # File check filepath = os.path.join(package.get_systempath(fullpath=True), filename) sys.stdout.write('## Saving to %s\n' % filepath) if os.path.isfile(filepath): if util.yes_no('## Overwrite?') == 'yes': newfilename = filepath + wasanbon.timestampstr() sys.stdout.write('## Rename existing file to %s\n' % os.path.basename(newfilename)) os.rename(filepath, newfilename) break else: break while True: sys.stdout.write('# Input Vendor Name:') vendorName = raw_input() sys.stdout.write('# Input Version:') version = raw_input() sys.stdout.write('# Input System Name (%s):' % package.name) systemName = raw_input() if len(systemName) == 0: systemName = package.name sys.stdout.write('# Input Description of System (abstract):') abstract = raw_input() sys.stdout.write('## Vendor Name = %s\n' % vendorName) sys.stdout.write('## Version = %s\n' % version) sys.stdout.write('## System Name = %s\n' % systemName) sys.stdout.write('## Abstract = %s\n' % abstract) if util.yes_no('# Okay?') == 'yes': break else: sys.stdout.write('# Retry') for i in range(5): try: sys.stdout.write('# Saving to %s\n' % filepath) admin.systemeditor.save_to_file(nss, filepath, system_name=systemName, abstract=abstract, version=version, vendor=vendorName, verbose=verbose) break except: traceback.print_exc() time.sleep(1.0) pass pass else: sys.stdout.write('## Aborted.')
def configure(self, args): """ Configure system interactively in console. $ mgr.py system configure """ self.parser.add_option( '-f', '--file', help= 'Configure with Specific RTSProfile (must be placed in system_dir', default=None, dest='systemfile', action='store', type='string') options, argv = self.parse_args(args[:]) verbose = options.verbose_flag package = admin.package.get_package_from_path(os.getcwd()) if options.systemfile: filename = os.path.join(package.get_systempath(), options.systemfile) else: filename = package.default_system_filepath from rtsprofile.rts_profile import RtsProfile file = open(filename, 'r') rtsprofile = RtsProfile(xml_spec=file) del (file) rtc_names = [rtc.instance_name for rtc in rtsprofile.components] from wasanbon import util def select_rtc(ans): rtc = rtsprofile.components[ans] confs = [] active_conf_index = -1 if len(rtc.configuration_sets) != 0: for i, conf in enumerate(rtc.configuration_sets): if conf.id == rtc.active_configuration_set: active_conf_index = i confs = conf.configuration_data conf_names = [conf.name + ':' + conf.data for conf in confs] def select_conf(ans2): key = confs[ans2].name sys.stdout.write('## INPUT (%s):' % key) val = raw_input() if util.yes_no('# %s = %s. Okay?' % (key, val)) == 'yes': rtc.configuration_sets[ active_conf_index].configuration_data[ans2].data = val return True return False util.choice(conf_names, select_conf, msg='# Select Configuration') return False util.choice(rtc_names, select_rtc, msg='# Select RTC') if util.yes_no("Save System?") != 'yes': sys.stdout.write('# Aborted \n') return 0 while True: if util.no_yes('Rename Filename?') == 'yes': filepath = os.path.join(package.get_systempath(), raw_input('Filename:')) else: filepath = filename newfile = filepath + wasanbon.timestampstr() try: os.rename(filepath, newfile) except Exception, e: sys.stdout.write( '## Exception occurred when renaming file.\n') traceback.print_exc() continue try: fout = open(filepath, 'w') fout.write(rtsprofile.save_to_xml()) fout.close() except: sys.stdout.write('## Exception occurred when saving file.\n') traceback.print_exc() continue break
def build(self, args): """ Build System in Console interactively $ mgr.py system build """ self.parser.add_option('-b', '--background', help='Launch in background(default=False)', default=False, action='store_true', dest='background_flag') self.parser.add_option( '-w', '--wakeuptimeout', help= 'Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons', default=5, dest='wakeuptimeout', action='store', type='float') options, argv = self.parse_args(args[:]) verbose = options.verbose_flag background = options.background_flag wakeuptimeout = options.wakeuptimeout #force = options.force_flag package = admin.package.get_package_from_path(os.getcwd(), verbose=verbose) global endflag endflag = False try: processes = admin.systemlauncher.launch_system(package, verbose=verbose) time.sleep(wakeuptimeout) package = admin.package.get_package_from_path(os.getcwd()) nss = admin.nameserver.get_nameservers_from_package( package, verbose=verbose) for ns in nss: ns.refresh(verbose=verbose) # Interactive Connect pairs = admin.systemeditor.get_connectable_pairs(nss, verbose=verbose) from wasanbon import util for pair in pairs: if util.no_yes( '# Connect? (%s->%s)\n' % (admin.systembuilder.get_port_full_path(pair[0]), admin.systembuilder.get_port_full_path( pair[1]))) == 'yes': while True: try: admin.systembuilder.connect_ports(pair[0], pair[1], verbose=verbose) sys.stdout.write('## Connected.\n') break except Exception, ex: if verbose: traceback.print_exc() pass sys.stdout.write('## Failed. \n') if util.yes_no('### Retry?') == 'no': break pass rtc_names = [] rtcs = [] for ns in nss: rtc_names = rtc_names + [ admin.systembuilder.get_component_full_path(rtc) for rtc in ns.rtcs ] rtcs = rtcs + ns.rtcs # Interactive Configure def select_rtc(ans): confs = admin.systemeditor.get_active_configuration_data( rtcs[ans]) conf_names = [conf.name + ':' + conf.data for conf in confs] def select_conf(ans2): key = confs[ans2].name sys.stdout.write(' INPUT (%s):' % key) val = raw_input() if util.yes_no('%s = %s. Okay?' % (key, val)) == 'yes': admin.systembuilder.set_active_configuration_data( rtcs[ans], key, val) return True return False util.choice(conf_names, select_conf, msg='Select Configuration') return False util.choice(rtc_names, select_rtc, msg='Select RTC') #Save Running System if util.yes_no('# Save System ?') == 'yes': filename = os.path.basename(package.default_system_filepath) while True: if util.yes_no('# Rename filename? (default:%s)' % filename) == 'yes': while True: sys.stdout.write('# Input:') val = raw_input() if util.yes_no('# New Filename = %s. Okay?' % val) == 'yes': filename = val break pass pass # File check filepath = os.path.join( package.get_systempath(fullpath=True), filename) sys.stdout.write('## Saving to %s\n' % filepath) if os.path.isfile(filepath): if util.yes_no('## Overwrite?') == 'yes': newfilename = filepath + wasanbon.timestampstr() sys.stdout.write( '## Rename existing file to %s\n' % os.path.basename(newfilename)) os.rename(filepath, newfilename) break else: break while True: sys.stdout.write('# Input Vendor Name:') vendorName = raw_input() sys.stdout.write('# Input Version:') version = raw_input() sys.stdout.write('# Input System Name (%s):' % package.name) systemName = raw_input() if len(systemName) == 0: systemName = package.name sys.stdout.write( '# Input Description of System (abstract):') abstract = raw_input() sys.stdout.write('## Vendor Name = %s\n' % vendorName) sys.stdout.write('## Version = %s\n' % version) sys.stdout.write('## System Name = %s\n' % systemName) sys.stdout.write('## Abstract = %s\n' % abstract) if util.yes_no('# Okay?') == 'yes': break else: sys.stdout.write('# Retry') for i in range(5): try: sys.stdout.write('# Saving to %s\n' % filepath) admin.systemeditor.save_to_file(nss, filepath, system_name=systemName, abstract=abstract, version=version, vendor=vendorName, verbose=verbose) break except: traceback.print_exc() time.sleep(1.0) pass pass else: sys.stdout.write('## Aborted.')
def compare_rtcprofile(rtcp, rtcp_real, verbose=False): import rtcprofile b = rtcprofile.RTCProfileBuilder(rtcp) modifiedFlag = False # compare dataports if verbose: sys.stdout.write('# Comparing RTC.xml with Running RTC(%s)\n' % (rtcp.name)) basicInfo_diff = False if rtcp_real.basicInfo.name != rtcp.basicInfo.name or \ rtcp_real.basicInfo.category != rtcp.basicInfo.category or \ rtcp_real.basicInfo.vendor != rtcp.basicInfo.vendor or \ rtcp_real.basicInfo.version != rtcp.basicInfo.version or \ rtcp_real.basicInfo.description != rtcp.basicInfo.description: from wasanbon import util if util.yes_no('# Basic Info is different. Update?:') == 'yes': b.setBasicInfo(rtcp_real.basicInfo.name, rtcp_real.basicInfo.category, rtcp_real.basicInfo.vendor, rtcp_real.basicInfo.version, rtcp_real.basicInfo.description) modifiedFlag = True for dp in rtcp.dataports: match_flag = False if verbose: sys.stdout.write( '# Searching DataPort in RTC %s : %s (written in RTC.xml)... ' % (dp['rtc:name'], dp['rtc:type'])) for dp_real in rtcp_real.dataports: if dp.equals(dp_real): match_flag = True break if not match_flag: # RTC.xml does not have dp if verbose: sys.stdout.write('## Not Found in the running RTC\n') b.removeDataPort(dp) modifiedFlag = True else: if verbose: sys.stdout.write('## Match.\n') for dp_real in rtcp_real.dataports: match_flag = False if verbose: sys.stdout.write( '# Searching DataPort in RTC.xml %s : %s (implemented in RTC)... ' % (dp_real['rtc:name'], dp_real['rtc:type'])) for dp in rtcp.dataports: if dp.equals(dp_real): match_flag = True break if not match_flag: # RTC.xml does not have dp if verbose: sys.stdout.write('## Not Found in the existing RTC.xml\n') b.appendDataPort(dp_real.portType, dp_real.type, dp_real.name) modifiedFlag = True else: if verbose: sys.stdout.write('## Match.\n') for sp in rtcp.serviceports: match_flag = False if verbose: sys.stdout.write( '# Searching ServicePort %s (writeen in RTC.xml) ...' % (sp['rtc:name'])) for sp_real in rtcp_real.serviceports: if sp.equals(sp_real): match_flag = True if verbose: sys.stdout.write('## Match.\n') for i in sp.serviceInterfaces: i_match_flag = False if verbose: sys.stdout.write( '## Searching ServiceInterface %s :: %s (written in RTC.xml) ... ' % (i.name, i.type)) for i_real in sp_real.serviceInterfaces: if i.equals(i_real): i_match_flag = True if verbose: sys.stdout.write('### Match\n') if not i_match_flag: if verbose: sys.stdout.write('### Not Found.\n') b.removeServiceInterfaceFromServicePort( sp.name, i.name) modifiedFlag = True break if not match_flag: if verbose: sys.stdout.write('## Not Found in the running RTC\n') b.removeServicePort(sp) modifiedFlag = True for sp_real in rtcp_real.serviceports: match_flag = False if verbose: sys.stdout.write( '# Searching ServicePort %s (implemented in RTC)' % (sp_real['rtc:name'])) for sp in rtcp.serviceports: if sp.equals(sp_real): match_flag = True if verbose: sys.stdout.write('## Match.\n') for i_real in sp_real.serviceInterfaces: i_match_flag = False if verbose: sys.stdout.write( '## Searching ServiceInterface %s :: %s (implemented in RTC)' % (i_real.name, i_real.type)) for i in sp.serviceInterfaces: if i.equals(i_real): i_match_flag = True if verbose: sys.stdout.write('### Match\n') if not i_match_flag: if verbose: sys.stdout.write('### Not Found.\n') b.appendServiceInterfaceToServicePort( sp_real.name, "", "", i_real.type, i_real.direction, i_real.name) modifiedFlag = True break if not match_flag: if verbose: sys.stdout.write('## Not Found in RTC.xml\n') b.appendServicePort(sp_real.name) for i in sp_real.serviceInterfaces: b.appendServiceInterfaceToServicePort(sp_real.name, "", "", i.type, i.direction, i.name) modifiedFlag = True if rtcp.configurationSet: for conf in rtcp.configurationSet.configurations: match_flag = False if verbose: sys.stdout.write( '# Searching Configuration %s (written in RTC.xml) ... ' % (conf.name)) for conf_real in rtcp_real.configurationSet.configurations: if conf.equals(conf_real): match_flag = True if verbose: sys.stdout.write('## Match\n') pass pass if not match_flag: if verbose: sys.stdout.write('## Not Found in the running RTC\n') b.removeConfiguration(conf.name) modifiedFlag = True pass pass pass for conf_real in rtcp_real.configurationSet.configurations: match_flag = False if verbose: sys.stdout.write( '# Searching Configuration %s (implemented in RTC) ...' % (conf_real.name)) if rtcp.configurationSet: for conf in rtcp.configurationSet.configurations: if conf.equals(conf_real): match_flag = True if verbose: sys.stdout.write('## Match\n') pass pass pass if not match_flag: if verbose: sys.stdout.write('## Not Found in the existing RTC.xml\n') b.appendConfiguration(conf_real.type, conf_real.name, conf_real.defaultValue) modifiedFlag = True pass pass if modifiedFlag: if verbose: sys.stdout.write("Modified.\n") return b.buildRTCProfile() if verbose: sys.stdout.write('Not Modified.\n') return None
def compare_rtcprofile(rtcp, rtcp_real, verbose=False): import rtcprofile b = rtcprofile.RTCProfileBuilder(rtcp) modifiedFlag = False # compare dataports if verbose: sys.stdout.write("# Comparing RTC.xml with Running RTC(%s)\n" % (rtcp.name)) basicInfo_diff = False if ( rtcp_real.basicInfo.name != rtcp.basicInfo.name or rtcp_real.basicInfo.category != rtcp.basicInfo.category or rtcp_real.basicInfo.vendor != rtcp.basicInfo.vendor or rtcp_real.basicInfo.version != rtcp.basicInfo.version or rtcp_real.basicInfo.description != rtcp.basicInfo.description ): from wasanbon import util if util.yes_no("# Basic Info is different. Update?:") == "yes": b.setBasicInfo( rtcp_real.basicInfo.name, rtcp_real.basicInfo.category, rtcp_real.basicInfo.vendor, rtcp_real.basicInfo.version, rtcp_real.basicInfo.description, ) modifiedFlag = True for dp in rtcp.dataports: match_flag = False if verbose: sys.stdout.write( "# Searching DataPort in RTC %s : %s (written in RTC.xml)... " % (dp["rtc:name"], dp["rtc:type"]) ) for dp_real in rtcp_real.dataports: if dp.equals(dp_real): match_flag = True break if not match_flag: # RTC.xml does not have dp if verbose: sys.stdout.write("## Not Found in the running RTC\n") b.removeDataPort(dp) modifiedFlag = True else: if verbose: sys.stdout.write("## Match.\n") for dp_real in rtcp_real.dataports: match_flag = False if verbose: sys.stdout.write( "# Searching DataPort in RTC.xml %s : %s (implemented in RTC)... " % (dp_real["rtc:name"], dp_real["rtc:type"]) ) for dp in rtcp.dataports: if dp.equals(dp_real): match_flag = True break if not match_flag: # RTC.xml does not have dp if verbose: sys.stdout.write("## Not Found in the existing RTC.xml\n") b.appendDataPort(dp_real.portType, dp_real.type, dp_real.name) modifiedFlag = True else: if verbose: sys.stdout.write("## Match.\n") for sp in rtcp.serviceports: match_flag = False if verbose: sys.stdout.write("# Searching ServicePort %s (writeen in RTC.xml) ..." % (sp["rtc:name"])) for sp_real in rtcp_real.serviceports: if sp.equals(sp_real): match_flag = True if verbose: sys.stdout.write("## Match.\n") for i in sp.serviceInterfaces: i_match_flag = False if verbose: sys.stdout.write( "## Searching ServiceInterface %s :: %s (written in RTC.xml) ... " % (i.name, i.type) ) for i_real in sp_real.serviceInterfaces: if i.equals(i_real): i_match_flag = True if verbose: sys.stdout.write("### Match\n") if not i_match_flag: if verbose: sys.stdout.write("### Not Found.\n") b.removeServiceInterfaceFromServicePort(sp.name, i.name) modifiedFlag = True break if not match_flag: if verbose: sys.stdout.write("## Not Found in the running RTC\n") b.removeServicePort(sp) modifiedFlag = True for sp_real in rtcp_real.serviceports: match_flag = False if verbose: sys.stdout.write("# Searching ServicePort %s (implemented in RTC)" % (sp_real["rtc:name"])) for sp in rtcp.serviceports: if sp.equals(sp_real): match_flag = True if verbose: sys.stdout.write("## Match.\n") for i_real in sp_real.serviceInterfaces: i_match_flag = False if verbose: sys.stdout.write( "## Searching ServiceInterface %s :: %s (implemented in RTC)" % (i_real.name, i_real.type) ) for i in sp.serviceInterfaces: if i.equals(i_real): i_match_flag = True if verbose: sys.stdout.write("### Match\n") if not i_match_flag: if verbose: sys.stdout.write("### Not Found.\n") b.appendServiceInterfaceToServicePort( sp_real.name, "", "", i_real.type, i_real.direction, i_real.name ) modifiedFlag = True break if not match_flag: if verbose: sys.stdout.write("## Not Found in RTC.xml\n") b.appendServicePort(sp_real.name) for i in sp_real.serviceInterfaces: b.appendServiceInterfaceToServicePort(sp_real.name, "", "", i.type, i.direction, i.name) modifiedFlag = True if rtcp.configurationSet: for conf in rtcp.configurationSet.configurations: match_flag = False if verbose: sys.stdout.write("# Searching Configuration %s (written in RTC.xml) ... " % (conf.name)) for conf_real in rtcp_real.configurationSet.configurations: if conf.equals(conf_real): match_flag = True if verbose: sys.stdout.write("## Match\n") pass pass if not match_flag: if verbose: sys.stdout.write("## Not Found in the running RTC\n") b.removeConfiguration(conf.name) modifiedFlag = True pass pass pass for conf_real in rtcp_real.configurationSet.configurations: match_flag = False if verbose: sys.stdout.write("# Searching Configuration %s (implemented in RTC) ..." % (conf_real.name)) if rtcp.configurationSet: for conf in rtcp.configurationSet.configurations: if conf.equals(conf_real): match_flag = True if verbose: sys.stdout.write("## Match\n") pass pass pass if not match_flag: if verbose: sys.stdout.write("## Not Found in the existing RTC.xml\n") b.appendConfiguration(conf_real.type, conf_real.name, conf_real.defaultValue) modifiedFlag = True pass pass if modifiedFlag: if verbose: sys.stdout.write("Modified.\n") return b.buildRTCProfile() if verbose: sys.stdout.write("Not Modified.\n") return None