예제 #1
0
    def __init__(self, apis, app, path, preferences):
        """
        Initializes the class.

        Keyword arguments:
        apis -- a list of API objects
        app -- the main application
        path -- path to the parent directory of the project
        preferences -- file name of the config file
        """
        QtWidgets.QMainWindow.__init__(self)
        self.apis = apis
        self.location = False
        self.locations = []
        self.treshold = {1: 600, 2: 500, 3: 200, 4: 100, 5: 50}
        self.path = path
        self.app = app
        self.preferences = ConfigObject(path + preferences)
        self._initializeWindow()
예제 #2
0
def _parseArguments():
    """
    Internal function that parses the command line arguments.

    Returns:
    A list of apis to be used in this session
    """
    parser = ArgumentParser()
    parser.add_argument("-g", "--graphicalhelp",
                        help="displays a graphical help page", dest="helpme",
                        action="store_true")
    parser.add_argument("-a", "--api", help="provide a list of APIs to use" +
                        " for the data data is shown. Available per " +
                        "default:\n\tTwitter",
                        dest="apis")
    parser.add_argument("--version", help="displays the version number and" +
                        " exits.", dest="v", action="store_true")
    parser.add_argument("-d", "--devel", help="displays developer infos" +
                        " and exits.", dest="d", action="store_true")
    parser.add_argument("-f", help="creates a config file with default " +
                        "values.", dest="conf", action="store_true")
    parser.add_argument("-l", help="stores error log in a file.",
                        dest="l", action="store_true")
    parser.add_argument("--log", help="stores error log in a specifically " +
                        "named file. Overrides the '-l' option.",
                        dest="log")
    parser.add_argument("--syscheck", help="checks whether the " +
                        "dependencies are met and installs them if wanted.",
                        dest="s", action="store_true")
    options, unknown = parser.parse_known_args()

    # if unknown:
    #     print("The following arguments are unknown: ", unknown, "\n")
    #     parser.print_help()
    #     sys.exit(1)

    if options.helpme:
        _openHelp()
        sys.exit(0)

    if options.v:
        print("Tangle Version:", _versionStr())
        sys.exit(0)

    if options.d:
        _showDevel()
        sys.exit(0)

    if options.conf:
        _makeConfFile()
        sys.exit(0)

    if options.log:
        _logToFile(options.log)
    elif options.l:
        _logToFile()

    if options.s:
        _sysCheck()
        sys.exit(0)

    if not options.apis:
        from util.ConfigObject import ConfigObject
        config = ConfigObject(path + "/src/config.json")
        apis = config.configs.value("apis", "WorldBank")
        return apis if type(apis) is list else [apis]
    else:
        return options.apis.split(',')