Exemplo n.º 1
0
QString ClassMethodDeclaration::toString() const
{
    if( !abstractType() )
        return ClassMemberDeclaration::toString();

    TypePtr<FunctionType> function = type<FunctionType>();
    if(function) {
        return QString("%1 %2 %3").arg(function->partToString( FunctionType::SignatureReturn ))
                                  .arg(prettyName().str())
                                  .arg(function->partToString( FunctionType::SignatureArguments ));
    } else {
        QString type = abstractType() ? abstractType()->toString() : QString("<notype>");
        kDebug(9505) << "A function has a bad type attached:" << type;
        return QString("invalid member-function %1 type %2").arg(prettyName().str()).arg(type);
    }
}
Exemplo n.º 2
0
Calamares::JobResult
DummyCppJob::exec()
{
    // Ported from dummypython
    QProcess::execute( "/bin/sh", QStringList() << "-c" << "touch ~/calamares-dummycpp" );
    QString accumulator = QDateTime::currentDateTimeUtc().toString( Qt::ISODate ) + '\n';
    accumulator += QStringLiteral( "Calamares version: " ) + CALAMARES_VERSION_SHORT + '\n';
    accumulator += QStringLiteral( "This job's name: " ) + prettyName() + '\n';
    accumulator += QStringLiteral( "Configuration map: %1\n" ).arg( variantMapToString( m_configurationMap ) );
    accumulator += QStringLiteral( "   *** globalstorage test ***\n" );
    Calamares::GlobalStorage *globalStorage = Calamares::JobQueue::instance()->globalStorage();
    accumulator += QStringLiteral( "lala: " ) + (globalStorage->contains( "lala" ) ? QStringLiteral( "true" ) : QStringLiteral( "false" )) + '\n';
    accumulator += QStringLiteral( "foo: " ) + (globalStorage->contains( "foo" ) ? QStringLiteral( "true" ) : QStringLiteral( "false" )) + '\n';
    accumulator += QStringLiteral( "count: " ) + QString::number( globalStorage->count() ) + '\n';
    globalStorage->insert( "item2", "value2" );
    globalStorage->insert( "item3", 3 );
    accumulator += QStringLiteral( "keys: %1\n" ).arg( globalStorage->keys().join( ',' ) );
    accumulator += QStringLiteral( "remove: %1\n" ).arg( QString::number( globalStorage->remove( "item2" ) ) );
    accumulator += QStringLiteral( "values: %1 %2 %3\n" ).arg(
        globalStorage->value( "foo" ).toString(),
        globalStorage->value( "item2" ).toString(),
        globalStorage->value( "item3" ).toString() );

    emit progress( 0.1 );
    cDebug() << "[DUMMYCPP]: " << accumulator;

    globalStorage->debugDump();
    emit progress( 0.5 );

    QThread::sleep( 3 );

    return Calamares::JobResult::ok();
}
Exemplo n.º 3
0
QWidget*
GUIBuilder::addElementGroup(model::gui::ElementGroup *root, QWidget *parent)
{
    QGroupBox* widget = new QGroupBox( parent );
    //widget->setFlat( true );

    const std::string key = root->key();
    if( root->showLabel() && !root->key().empty() ) {
        widget->setTitle( (prettyName( root->key(), m_model ) ).c_str() );
    }

    model::gui::Element* child = root->child();
    if( child != NULL ) {
        if( child->type() == model::gui::GRID ) {
            doGridLayout( static_cast<model::gui::Grid*>( child ), widget );
        }
        else if( child->type() == model::gui::HORIZONTAL_LAYOUT ) {
            doHorizontalLayout( static_cast<model::gui::HorizontalLayout*>( child ), widget );
        }
        else if( child->type() == model::gui::VERTICAL_LAYOUT ) {
            doVerticalLayout( static_cast<model::gui::VerticalLayout*>( child ), widget );
        }
        else {
            QHBoxLayout* layout = new QHBoxLayout( widget );
            widget->setLayout( layout );
            addChildren( static_cast<model::gui::Container0D<model::gui::Element>*>( root ),
                         widget,
                         layout );
        }
    }
    return widget;
}
void Aggregate::merger() {

    // Just sleep for a while
    // Only for syncronization in main loop
    boost::this_thread::sleep(boost::posix_time::millisec(500));

    // If total size downloaded isn't equal
    // to the size of file downloaded then
    // do not merge the Chunks
    if( m_filesize != bytesTotal())
        Throw(ex::Error,"Downloaded bytes greater than total filesize.");

    fancyprint("Merging!",NOTIFY);
    fancyprint("Do not close this window.",WARNING);
    File tmp(tempName());
    tmp.write(Node::FORCE);
    // TODO try binary appends and storing to "tmp"
    // Append the content to "tmp"
    for(unsigned i=0; i < m_chunk.size(); i++){
        print(i+1 << " of " << m_chunk.size());
        tmp.append(*(m_chunk[i]->file()));
        std::cout << DELETE;
    }
    std::cout << DELETE;
    tmp.move(prettyName(),Node::NEW);
    // Remove the old directory
    Directory(m_hashedUrl).remove(Node::FORCE);

    fancyprint("Complete!",SUCCESS);
}
Exemplo n.º 5
0
void
ServiceBase::generateWidgetInfo( const QString &html ) const
{
    QVariantMap map;
    map["service_name"] = prettyName();
    map["main_info"] = html;
    The::infoProxy()->setInfo( map );
}
Exemplo n.º 6
0
QString StructureType::toString() const
{
    if ( d_func()->prettyName.isEmpty() ) {
        return KDevelop::StructureType::toString();
    } else {
        return prettyName().str();
    }
}
Exemplo n.º 7
0
void
ServiceBase::infoChanged( const QString &infoHtml )
{
    QVariantMap map;
    map["service_name"] = prettyName();
    map["main_info"] = infoHtml;
    The::infoProxy()->setInfo( map );
}
Exemplo n.º 8
0
int Enum::enumValue(const QString &enumerator) const
{
    EnumValueHash::const_iterator it = _enumValues.constFind(enumerator);
    if (it == _enumValues.constEnd())
        baseTypeError(QString("Enumerator '%0' does not exist in %1 (0x%2)")
                      .arg(enumerator)
                      .arg(prettyName())
                      .arg((uint)id(), 0, 16));
    return it.value();
}
Exemplo n.º 9
0
void printUnhandledException(const char *iname, const std::exception *e)
{
    if (e)
        printErr(iname,"unhandled exception: %s\n", prettyName(e->what()));
    else
        printErr(iname,"internal error: unhandled exception!\n");
    if (opt->cmd != CMD_COMPRESS)
    {
        printErr(iname,"  this file has possibly been modified/hacked; take care!\n");
    }
}
Exemplo n.º 10
0
void Control3DManager::addControl(PropertyReflection *prop, const std::string &controlName, const std::string &label) {
	try {
		Control3D *control = FIND_CONTROL_3D(controlName);
		prop->accept(*control);
		Gtk::TreeModel::Row row = *(_treeModel->append());
		if (label == "") row[_columns.col_name] = prettyName(prop->getName());
		else row[_columns.col_name] = label;
		row[_columns.col_visible] = true;
		row[_columns.col_control] = control;
	} catch (UnknownClassException &e) {
		LOG("Unknown 3D control: "+controlName, Log::ERROR);
	}
}
Exemplo n.º 11
0
string AstNode::vcdName(const string& namein) {
    // VCD tracing expects space to separate hierarchy
    // Dots are reserved for dots the user put in the name
    string pretty = namein;
    string::size_type pos;
    while ((pos=pretty.find("__DOT__")) != string::npos) {
	pretty.replace(pos, 7, " ");
    }
    while ((pos=pretty.find(".")) != string::npos) {
	pretty.replace(pos, 1, " ");
    }
    // Now convert escaped special characters, etc
    return prettyName(pretty);
}
Exemplo n.º 12
0
void UpnpCollectionBase::slotRemoveJob(KJob* job)
{
    KIO::SimpleJob *sj = static_cast<KIO::SimpleJob*>( job );

    m_jobSet.remove( sj );

    if( sj->error() ) {
        m_continuousJobFailureCount++;
        if( m_continuousJobFailureCount >= MAX_JOB_FAILURES_BEFORE_ABORT ) {
            debug() << prettyName() << "Had" << m_continuousJobFailureCount << "continuous job failures, something wrong with the device. Removing this collection.";
            emit remove();
        }
    }
    else {
        m_continuousJobFailureCount = 0;
    }
}
Exemplo n.º 13
0
void printErr(const char *iname, const Throwable *e)
{
    char buf[1024];
    size_t l;

    upx_snprintf(buf, sizeof(buf), "%s", prettyName(typeid(*e).name()));
//    upx_snprintf(buf, sizeof(buf), "%s", e->getMsg());
    l = strlen(buf);
    if (l < sizeof(buf) && e->getMsg())
        upx_snprintf(buf+l, sizeof(buf)-l, ": %s", e->getMsg());
    l = strlen(buf);
    if (l < sizeof(buf) && e->getErrno()) {
        upx_snprintf(buf+l, sizeof(buf)-l, ": %s", strerror(e->getErrno()));
#if 1
        // some compilers (e.g. Borland C++) put a trailing '\n'
        // into strerror() result
        l = strlen(buf);
        while (l-- > 0 && (buf[l] == '\n' || buf[l] == ' '))
            buf[l] = 0;
#endif
    }
    pr_error(iname,buf,e->isWarning());
}
Exemplo n.º 14
0
QWidget*
GUIBuilder::addTabLayout(model::gui::TabLayout *root, QWidget *parent)
{
    QTabWidget* tabWidget = new QTabWidget(parent);

    for( size_t i=0; i<root->children(); i++ ) {
        model::gui::Tab* tab = root->child( i );
        if( tab != NULL ) {
            QWidget* child = buildGUI( tab->child(), tabWidget );
            if( child != NULL ) {
                tabWidget->addTab( child,
                                   QString(prettyName(tab->key(), m_model).c_str()) );
            }
            else {
                std::cerr << __FILE__ << '@' << __LINE__<< ": ERROR: got nullptr.\n";
            }
        }
        else {
            std::cerr << __FILE__ << '@' << __LINE__<< ": ERROR: child is not tab.\n";
        }
    }
    tabWidget->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
   return tabWidget;
}
Exemplo n.º 15
0
QString NamespaceAliasDeclaration::toString() const
{
  return QStringLiteral("Import %1 as %2").arg(d_func()->m_importIdentifier.identifier().toString(), prettyName().str());
}
Exemplo n.º 16
0
JobResult
PythonJob::exec()
{
    // We assume m_scriptFile to be relative to m_workingPath.
    QDir workingDir( m_workingPath );
    if ( !workingDir.exists() ||
         !workingDir.isReadable() )
    {
        return JobResult::error( tr( "Bad working directory path" ),
                                 tr( "Working directory %1 for python job %2 is not readable." )
                                    .arg( m_workingPath )
                                    .arg( prettyName() ) );
    }

    QFileInfo scriptFI( workingDir.absoluteFilePath( m_scriptFile ) );
    if ( !scriptFI.exists() ||
         !scriptFI.isFile() ||
         !scriptFI.isReadable() )
    {
        return JobResult::error( tr( "Bad main script file" ),
                                 tr( "Main script file %1 for python job %2 is not readable." )
                                    .arg( scriptFI.absoluteFilePath() )
                                    .arg( prettyName() ) );
    }

    try
    {
        bp::dict scriptNamespace = helper()->createCleanNamespace();

        bp::object calamaresModule = bp::import( "libcalamares" );
        bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );

        calamaresNamespace[ "job" ] = CalamaresPython::PythonJobInterface( this );
        calamaresNamespace[ "globalstorage" ] = CalamaresPython::GlobalStoragePythonWrapper(
                                                JobQueue::instance()->globalStorage() );

        bp::object execResult = bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(),
                                           scriptNamespace,
                                           scriptNamespace );

        bp::object entryPoint = scriptNamespace[ "run" ];
        bp::object prettyNameFunc = scriptNamespace.get("pretty_name", bp::object());

        cDebug() << "Job file" << scriptFI.absoluteFilePath();
        if ( !prettyNameFunc.is_none() )
        {
            bp::extract< std::string > prettyNameResult( prettyNameFunc() );
            if ( prettyNameResult.check() )
            {
                m_description = QString::fromStdString( prettyNameResult() ).trimmed();
            }
            if ( !m_description.isEmpty() )
            {
                cDebug() << "Job description from pretty_name" << prettyName() << "=" << m_description;
                emit progress( 0 );
            }
        }

        if ( m_description.isEmpty() )
        {
            bp::extract< std::string > entryPoint_doc_attr(entryPoint.attr( "__doc__" ) );

            if ( entryPoint_doc_attr.check() )
            {
                m_description = QString::fromStdString( entryPoint_doc_attr() ).trimmed();
                auto i_newline = m_description.indexOf('\n');
                if ( i_newline > 0 )
                    m_description.truncate( i_newline );
                cDebug() << "Job description from __doc__" << prettyName() << "=" << m_description;
                emit progress( 0 );
            }
        }

        bp::object runResult = entryPoint();

        if ( runResult.is_none() )
        {
            return JobResult::ok();
        }
        else // Something happened in the Python job
        {
            bp::tuple resultTuple = bp::extract< bp::tuple >( runResult );
            QString message = QString::fromStdString( bp::extract< std::string >( resultTuple[ 0 ] ) );
            QString description = QString::fromStdString( bp::extract< std::string >( resultTuple[ 1 ] ) );
            return JobResult::error( message, description );
        }
    }
    catch ( bp::error_already_set )
    {
        QString msg;
        if ( PyErr_Occurred() )
        {
            msg = helper()->handleLastError();
        }
        bp::handle_exception();
        PyErr_Clear();
        return JobResult::internalError(
                    tr( "Boost.Python error in job \"%1\"." ).arg( prettyName() ),
                    msg,
                    JobResult::PythonUncaughtException );
    }
}
Exemplo n.º 17
0
string AstNode::prettyTypeName() const {
    if (name()=="") return typeName();
    return string(typeName())+" '"+prettyName()+"'";
}
Exemplo n.º 18
0
QString
CheckFileSystemJob::prettyStatusMessage() const
{
    return prettyName();
}
Exemplo n.º 19
0
QString CostItem::fullName() const
{
    return QStringLiteral("%1 %2")
            .arg(ProfileContext::typeName(type())).arg(prettyName());
}