def test_convert_html_to_text(self):
     import roslib.stacks
     from rosdeb.rosutil import convert_html_to_text
     from roslib.stack_manifest import parse_file, stack_file
     for stack_name in roslib.stacks.list_stacks():
         stack_xml = stack_file(stack_name)
         m = roslib.stack_manifest.parse_file(stack_xml)
         converted = convert_html_to_text(m.description)
         # some stacks do in fact have empty descriptions
         if stack_name in ['ros', 'common_msgs', 'navigation', 'geometry']:
             self.assert_(converted)
             
         # hard to actually validate output stable-y
         if stack_name == 'ros_release':
             self.assert_('* rosinstall' in converted, converted)
             self.assert_('* Debian toolchains' in converted, converted)
             self.assert_('p>' not in converted)                
             self.assert_('<ul>' not in converted)                
Esempio n. 2
0
    def test_convert_html_to_text(self):
        import roslib.stacks
        from rosdeb.rosutil import convert_html_to_text
        from roslib.stack_manifest import parse_file, stack_file
        for stack_name in roslib.stacks.list_stacks():
            stack_xml = stack_file(stack_name)
            m = roslib.stack_manifest.parse_file(stack_xml)
            converted = convert_html_to_text(m.description)
            # some stacks do in fact have empty descriptions
            if stack_name in ['ros', 'common_msgs', 'navigation', 'geometry']:
                self.assert_(converted)

            # hard to actually validate output stable-y
            if stack_name == 'ros_release':
                self.assert_('* rosinstall' in converted, converted)
                self.assert_('* Debian toolchains' in converted, converted)
                self.assert_('p>' not in converted)
                self.assert_('<ul>' not in converted)
def control_data(stack_name, stack_version, md5sum, stack_file=None):
    """
    Generate metadata for control file. Cannot generate debian dependencies as these are platform specific.
    
    @type  stack_name: name of stack
    @type  stack_name: str
    @type  stack_version: stack version id
    @type  stack_version: str
    @param stack_file: location of stack file, or None to use default rosstack lookup
    @type  stack_file: str
    """
    import roslib.stack_manifest
    if stack_file is None:
        stack_file = roslib.stack_manifest.stack_file(stack_name)
    m = roslib.stack_manifest.parse_file(stack_file)

    metadata = {}

    metadata['md5sum'] = md5sum  #3301
    metadata['stack'] = stack_name
    metadata['package'] = debianize_name(stack_name)
    metadata['version'] = stack_version
    metadata['homepage'] = m.url
    if m.author.startswith('Maintained by '):
        metadata['maintainer'] = m.author[len('Maintained by '):]
    else:
        metadata['maintainer'] = m.author
    metadata['priority'] = 'optional'
    if m.brief:
        # 60-char limit on control files
        metadata['description-brief'] = m.brief[:60]
    else:
        metadata['description-brief'] = m.brief[:60]

    try:
        description = convert_html_to_text(m.description).rstrip()
    except:
        description = "unknown"

    # per debian spec, single-space pad to signal paragraph
    desc_padded = ''
    for l in description.split('\n'):
        desc_padded += ' ' + l + '\n'
    metadata['description-full'] = desc_padded.rstrip()

    # do deps in two parts as ros stack depends need to become version
    # locked later on due to lack of ABI compat
    metadata['depends'] = [d.stack for d in m.depends]
    metadata['rosdeps'] = rosdeps = {}
    for platform in platforms():
        try:
            rosdeps[platform] = stack_rosdeps(stack_name,
                                              os.path.dirname(stack_file),
                                              platform)
        except Exception as e:
            # #3435
            # TODO: this is a hack that should be turned into a typed exception
            if "cannot generate" in str(e):
                sys.stderr.write("Error with platform [%s]: %s\n" %
                                 (platform, str(e)))
            # ignore other failures as these are generally unsupported
            # platforms. Later logic is responsible for erroring if
            # control file is missing bindings, and unit tests on
            # stack_rosdeps verify its functionality

    return metadata
Esempio n. 4
0
def send_email(smtp_server, from_addr, to_addrs, subject, text):
    import smtplib
    from email.mime.text import MIMEText

    msg = MIMEText(text)

    msg['From'] = from_addr
    msg['To'] = to_addrs
    msg['Subject'] = subject

    s = smtplib.SMTP(smtp_server)
    print 'Sending mail to %s'%(to_addrs)
    try:
        s.sendmail(msg['From'], [msg['To']], msg.as_string())
    except Exception, ex:
        print "Sending email failed with exception: %s" % ex
    s.quit()

if __name__ == '__main__':
    import roslib.stacks
    from rosdeb.rosutil import convert_html_to_text
    from roslib.stack_manifest import parse_file, stack_file
    for stack_name in roslib.stacks.list_stacks():
        stack_xml = stack_file(stack_name)
        m = roslib.stack_manifest.parse_file(stack_xml)
        if stack_name in ['ros_release']:
            print '='*80
            print stack_name
            print convert_html_to_text(m.description)

def control_data(stack_name, stack_version, md5sum, stack_file=None):
    """
    Generate metadata for control file. Cannot generate debian dependencies as these are platform specific.
    
    @type  stack_name: name of stack
    @type  stack_name: str
    @type  stack_version: stack version id
    @type  stack_version: str
    @param stack_file: location of stack file, or None to use default rosstack lookup
    @type  stack_file: str
    """
    import roslib.stack_manifest
    if stack_file is None:
        stack_file = roslib.stack_manifest.stack_file(stack_name)
    m = roslib.stack_manifest.parse_file(stack_file)

    metadata = {}
    
    metadata['md5sum']     = md5sum #3301
    metadata['stack']      = stack_name
    metadata['package']    = debianize_name(stack_name)
    metadata['version']    = stack_version
    metadata['homepage']   = m.url
    if m.author.startswith('Maintained by '):
        metadata['maintainer'] = m.author[len('Maintained by '):]
    else:
        metadata['maintainer'] = m.author        
    metadata['priority']   = 'optional'
    if m.brief:
        # 60-char limit on control files
        metadata['description-brief'] = m.brief[:60]
    else:
        metadata['description-brief'] = m.brief[:60]

    try:
        description = convert_html_to_text(m.description).rstrip()
    except:
        description = "unknown"

    # per debian spec, single-space pad to signal paragraph
    desc_padded = ''
    for l in description.split('\n'):
        desc_padded += ' '+l+'\n'
    metadata['description-full'] = desc_padded.rstrip()

    # do deps in two parts as ros stack depends need to become version
    # locked later on due to lack of ABI compat
    metadata['depends'] = [d.stack for d in m.depends]
    metadata['rosdeps'] = rosdeps = {}
    for platform in platforms():
        try:
            rosdeps[platform] = stack_rosdeps(stack_name, os.path.dirname(stack_file), platform)
        except Exception as e:
            # #3435
            # TODO: this is a hack that should be turned into a typed exception
            if "cannot generate" in str(e):
                sys.stderr.write("Error with platform [%s]: %s\n"%(platform, str(e)))
            # ignore other failures as these are generally unsupported
            # platforms. Later logic is responsible for erroring if
            # control file is missing bindings, and unit tests on
            # stack_rosdeps verify its functionality
    
    return metadata