~ubuntu-branches/ubuntu/quantal/marble/quantal

« back to all changes in this revision

Viewing changes to tools/osm-sisyphus/main.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Kolberg
  • Date: 2012-05-26 15:14:42 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120526151442-qihwzeki8qlr9ip4
Tags: 4:4.8.80-0ubuntu1
New upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// This file is part of the Marble Virtual Globe.
 
3
//
 
4
// This program is free software licensed under the GNU LGPL. You can
 
5
// find a copy of this license in LICENSE.txt in the top directory of
 
6
// the source code.
 
7
//
 
8
// Copyright 2011      Dennis Nienhüser <earthwings@gentoo.org>
 
9
//
 
10
 
 
11
#include "jobmanager.h"
 
12
#include "logger.h"
 
13
#include "upload.h"
 
14
 
 
15
#include <QtCore/QCoreApplication>
 
16
#include <QtCore/QDebug>
 
17
 
 
18
void usage(const QString &app)
 
19
{
 
20
    qDebug() << "Usage: " << app << "[options] regions.xml log.sqlite [resume-id]";
 
21
    qDebug() << "\nOptions:";
 
22
    qDebug() << "\t-h, --help................. Show this help";
 
23
    qDebug() << "\t-cd, --cache-data.......... Do not delete downloaded .osm.pbf and converted .tar.gz files after a successful conversion and upload";
 
24
    qDebug() << "\t-nu, --no-uploads.......... Do not upload converted files to files.kde.org";
 
25
}
 
26
 
 
27
int main(int argc, char *argv[])
 
28
{
 
29
    QCoreApplication app(argc, argv);
 
30
 
 
31
    QStringList arguments;
 
32
    bool cacheData(false);
 
33
    bool uploadFiles(true);
 
34
    for (int i=1; i<argc; ++i) {
 
35
        QString const arg = argv[i];
 
36
        if (arg == "-h" || arg == "--help") {
 
37
            usage(argv[0]);
 
38
            return 0;
 
39
        } else if (arg == "-cd" || arg == "--cache-data") {
 
40
            cacheData = true;
 
41
        } else if (arg == "-nu" || arg == "--no-uploads") {
 
42
            uploadFiles = false;
 
43
        } else {
 
44
            arguments << arg;
 
45
        }
 
46
    }
 
47
 
 
48
    if (arguments.size() < 2) {
 
49
        usage(argv[0]);
 
50
        return 1;
 
51
    }
 
52
 
 
53
    Logger::instance().setFilename(arguments.at(1));
 
54
 
 
55
    QFileInfo tempDir = QFileInfo(QDir::tempPath(), "osm-sisyphus");
 
56
    JobParameters parameters;
 
57
    parameters.setBase(QDir(tempDir.absoluteFilePath()));
 
58
    parameters.setCacheData(cacheData);
 
59
 
 
60
    Upload::instance().setJobParameters(parameters);
 
61
    Upload::instance().setUploadFiles(uploadFiles);
 
62
 
 
63
    JobManager manager;
 
64
    manager.setRegionsFile(arguments.at(0));
 
65
    manager.setJobParameters(parameters);
 
66
    if (arguments.size() == 3) {
 
67
        manager.setResumeId(arguments.at(2));
 
68
    }
 
69
    manager.run();
 
70
    
 
71
    return app.exec();
 
72
}