Julio Biason
16 years ago
2 changed files with 0 additions and 106 deletions
@ -1,106 +0,0 @@
|
||||
#!/usr/bin/python2.5 |
||||
# -*- coding: utf-8 -*- |
||||
|
||||
# Mitter, a Maemo client for Twitter. |
||||
# Copyright (C) 2007, 2008 Julio Biason |
||||
# |
||||
# This program is free software: you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation, either version 3 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
||||
import time |
||||
import urllib |
||||
import os |
||||
import logging |
||||
import warnings |
||||
|
||||
import mitterlib.network as network |
||||
|
||||
from mitterlib.configopt import ConfigOpt |
||||
from mitterlib.network import Networks |
||||
from mitterlib import ui |
||||
|
||||
log = logging.getLogger('mitter') |
||||
|
||||
|
||||
def main(): |
||||
"""Main function.""" |
||||
|
||||
# options |
||||
|
||||
options = ConfigOpt() |
||||
options.add_group('General', 'General options') |
||||
options.add_option('-d', '--debug', |
||||
group='General', |
||||
option='debug', |
||||
action='store_true', |
||||
help='Display debugging information.', |
||||
default=False, |
||||
is_config_option=False) |
||||
options.add_option('-i', '--interface', |
||||
group='General', |
||||
option='interface', |
||||
default=None, |
||||
metavar='INTERFACE', |
||||
help='Interface to be used.') |
||||
|
||||
# Ask networks to add their options |
||||
|
||||
connection = Networks(options) |
||||
|
||||
# Ask interfaces to add their options |
||||
|
||||
ui.interface_options(options) |
||||
|
||||
# Parse the command line options and the config file |
||||
|
||||
options() |
||||
|
||||
# start the logging service |
||||
|
||||
if options['General']['debug']: |
||||
logging.basicConfig(level=logging.DEBUG) |
||||
else: |
||||
logging.basicConfig(level=logging.INFO) |
||||
log = logging.getLogger('mitter') |
||||
|
||||
# disable the warnings. Interfaces may choose to receive the warnings |
||||
# changing the filter to "error" |
||||
warnings.simplefilter('ignore') |
||||
|
||||
# select an interface (preferably, the one the user selected in the |
||||
# command line) |
||||
preferred_interface = options['General']['interface'] |
||||
log.debug('Config interface: %s', preferred_interface) |
||||
|
||||
if 'interface' in options.conflicts: |
||||
preferred_interface = options.conflicts['interface'] |
||||
log.debug('Command line interface: %s', preferred_interface) |
||||
|
||||
interface = ui.interface(preferred_interface) |
||||
|
||||
if interface is None: |
||||
log.error('Sorry, no interface could be found for your system') |
||||
return |
||||
|
||||
# now start the twitter connection |
||||
log.debug('Starting networks') |
||||
connection = Networks(options) |
||||
display = interface.Interface(connection, options) |
||||
|
||||
# display the interface (the interface should take care of updating |
||||
# itself) |
||||
display() |
||||
options.save() |
||||
|
||||
if __name__ == '__main__': |
||||
main() |
Loading…
Reference in new issue