コード例 #1
0
ファイル: utils.py プロジェクト: coddingtonbear/d-rats
def init_icon_maps():
    global ICON_MAPS

    ICON_MAPS = {
        "/" : open_icon_map(os.path.join(platform.get_platform().source_dir(),
                                         "images", "aprs_pri.png")),
        "\\": open_icon_map(os.path.join(platform.get_platform().source_dir(),
                                         "images", "aprs_sec.png")),
        }
コード例 #2
0
 def __init__(self, i2c):
     self.i2c = i2c
     platform.get_platform()
     if platform.platform_pyb:
         self.i2c_send = self.pyb_i2c_send
         self.i2c_recv = self.pyb_i2c_recv
     else:
         if platform.platform_esp:
             self.i2c_send = self.esp_i2c_send
             self.i2c_recv = self.esp_i2c_recv
         else:
             raise platform.PlatformError('unknow platform')
コード例 #3
0
    def do_browse(self, _, dir):
        if self.filename.get_text():
            start = os.path.dirname(self.filename.get_text())
        else:
            start = None

        if dir:
            fn = platform.get_platform().gui_select_dir(start)
        else:
            fn = platform.get_platform().gui_save_file(start)
        if fn:
            self.filename.set_text(fn)
コード例 #4
0
ファイル: utils.py プロジェクト: SullivanChrisJ/drats
def init_icon_maps():
    global ICON_MAPS

    ICON_MAPS = {
        "/":
        open_icon_map(
            os.path.join(platform.get_platform().source_dir(), "images",
                         "aprs_pri.png")),
        "\\":
        open_icon_map(
            os.path.join(platform.get_platform().source_dir(), "images",
                         "aprs_sec.png")),
    }
コード例 #5
0
ファイル: version.py プロジェクト: Multiface24111/hata
def __main__():
    output_parts = []

    output_parts.append(PACKAGE_NAME[0].upper())
    output_parts.append(PACKAGE_NAME[1:])
    output_parts.append(' version: ')
    output_parts.append(VERSION)
    output_parts.append('\n')

    output_parts.append('Platform: ')
    output_parts.append(get_platform())
    output_parts.append('\n')

    implementation = sys.implementation

    output_parts.append('Python implementation: ')
    output_parts.append(implementation.name)
    output_parts.append('\n')

    version = implementation.version

    output_parts.append('Python version: ')
    output_parts.append(str(version[0]))
    output_parts.append('.')
    output_parts.append(str(version[1]))

    if version[3] == 'final':
        output_parts.append(' final')

    output_parts.append('\n')

    output = ''.join(output_parts)

    sys.stdout.write(output)
コード例 #6
0
ファイル: qst.py プロジェクト: coddingtonbear/d-rats
    def do_qst(self):
        size_limit = self.config.getint("settings", "qst_size_limit")
        pform = platform.get_platform()
        s, o = pform.run_sync(self.text)
        if s:
            print "Command failed with status %i" % s

        return o[:size_limit]
コード例 #7
0
    def do_qst(self):
        size_limit = self.config.getint("settings", "qst_size_limit")
        pform = platform.get_platform()
        s, o = pform.run_sync(self.text)
        if s:
            print "Command failed with status %i" % s

        return o[:size_limit]
コード例 #8
0
ファイル: map_sources.py プロジェクト: yanicky/d-rats
 def do_update(self):
     p = platform.get_platform()
     try:
         fn, headers = p.retrieve_url(self.__url)
         content = file(fn).read()
     except Exception, e:
         print "[NBDC] Failed to fetch info for %i: %s" % (self.__buoy, e)
         self.set_name("NBDC %s" % self.__buoy)
         return
コード例 #9
0
    def __init__(self):
        # create root logger
        self.logger = logging.getLogger()
        self.logger.setLevel(logging.DEBUG)

        self.LOG = logging.getLogger(__name__)

        # Set CHIRP_DEBUG in environment for early console debugging.
        # It can be a number or a name; otherwise, level is set to 'debug'
        # in order to maintain backward compatibility.
        CHIRP_DEBUG = os.getenv("CHIRP_DEBUG")
        self.early_level = logging.WARNING
        if CHIRP_DEBUG:
            try:
                self.early_level = int(CHIRP_DEBUG)
            except ValueError:
                try:
                    self.early_level = log_level_names[CHIRP_DEBUG]
                except KeyError:
                    self.early_level = logging.DEBUG

        # If we're on Win32 or MacOS, we don't use the console; instead,
        # we create 'debug.log', redirect all output there, and set the
        # console logging handler level to DEBUG.  To test this on Linux,
        # set CHIRP_DEBUG_LOG in the environment.
        console_stream = None
        console_format = '%(levelname)s: %(message)s'
        if 'CHIRP_TESTENV' not in os.environ and (
                hasattr(sys, "frozen") or not os.isatty(0)
                or os.getenv("CHIRP_DEBUG_LOG")):
            p = platform.get_platform()
            log = file(p.config_file("debug.log"), "w", 0)
            sys.stdout = log
            sys.stderr = log
            console_stream = log
            console_format = self.log_format
            self.early_level = logging.DEBUG

        self.console = logging.StreamHandler(console_stream)
        self.console_level = self.early_level
        self.console.setLevel(self.early_level)
        self.console.setFormatter(logging.Formatter(console_format))
        self.logger.addHandler(self.console)

        # Set CHIRP_LOG in environment to the name of log file.
        logname = os.getenv("CHIRP_LOG")
        self.logfile = None
        if logname is not None:
            self.create_log_file(logname)
            level = os.getenv("CHIRP_LOG_LEVEL")
            if level is not None:
                self.set_log_verbosity(level)
            else:
                self.set_log_level(logging.DEBUG)

        if self.early_level <= logging.DEBUG:
            self.LOG.debug(version_string())
コード例 #10
0
ファイル: logger.py プロジェクト: tylert/chirp.hg
    def __init__(self):
        # create root logger
        self.logger = logging.getLogger()
        self.logger.setLevel(logging.DEBUG)

        self.LOG = logging.getLogger(__name__)

        # Set CHIRP_DEBUG in environment for early console debugging.
        # It can be a number or a name; otherwise, level is set to 'debug'
        # in order to maintain backward compatibility.
        CHIRP_DEBUG = os.getenv("CHIRP_DEBUG")
        self.early_level = logging.WARNING
        if CHIRP_DEBUG:
            try:
                self.early_level = int(CHIRP_DEBUG)
            except ValueError:
                try:
                    self.early_level = log_level_names[CHIRP_DEBUG]
                except KeyError:
                    self.early_level = logging.DEBUG

        # If we're on Win32 or MacOS, we don't use the console; instead,
        # we create 'debug.log', redirect all output there, and set the
        # console logging handler level to DEBUG.  To test this on Linux,
        # set CHIRP_DEBUG_LOG in the environment.
        console_stream = None
        console_format = '%(levelname)s: %(message)s'
        if 'CHIRP_TESTENV' not in os.environ and (
                hasattr(sys, "frozen") or not os.isatty(0) or
                os.getenv("CHIRP_DEBUG_LOG")):
            p = platform.get_platform()
            log = file(p.config_file("debug.log"), "w", 0)
            sys.stdout = log
            sys.stderr = log
            console_stream = log
            console_format = self.log_format
            self.early_level = logging.DEBUG

        self.console = logging.StreamHandler(console_stream)
        self.console_level = self.early_level
        self.console.setLevel(self.early_level)
        self.console.setFormatter(logging.Formatter(console_format))
        self.logger.addHandler(self.console)

        # Set CHIRP_LOG in environment to the name of log file.
        logname = os.getenv("CHIRP_LOG")
        self.logfile = None
        if logname is not None:
            self.create_log_file(logname)
            level = os.getenv("CHIRP_LOG_LEVEL")
            if level is not None:
                self.set_log_verbosity(level)
            else:
                self.set_log_level(logging.DEBUG)

        if self.early_level <= logging.DEBUG:
            self.LOG.debug(version_string())
コード例 #11
0
ファイル: gps.py プロジェクト: yanicky/d-rats
 def display_in_browser(self):
     f = tempfile.NamedTemporaryFile(suffix=".html")
     name = f.name
     f.close()
     f = file(name, "w")
     f.write(self.make_html())
     f.flush()
     f.close()
     p = platform.get_platform()
     p.open_html_file(f.name)
コード例 #12
0
ファイル: gps.py プロジェクト: coddingtonbear/d-rats
 def display_in_browser(self):
     f = tempfile.NamedTemporaryFile(suffix=".html")
     name = f.name
     f.close()
     f = file(name, "w")
     f.write(self.make_html())
     f.flush()
     f.close()
     p = platform.get_platform()
     p.open_html_file(f.name)
コード例 #13
0
ファイル: map_sources.py プロジェクト: yanicky/d-rats
    def __parse_site(self):
        url = "http://waterdata.usgs.gov/nwis/inventory?search_site_no=%s&format=sitefile_output&sitefile_output_format=xml&column_name=agency_cd&column_name=site_no&column_name=station_nm&column_name=dec_lat_va&column_name=dec_long_va&column_name=alt_va" % self.__site

        p = platform.get_platform()
        try:
            fn, headers = p.retrieve_url(url)
            content = file(fn).read()
        except Exception, e:
            print "[NSGS] Failed to fetch info for %s: %s" % (self.__site, e)
            self.set_name("NSGS NWIS Site %s" % self.__site)
            return
コード例 #14
0
 def create_form_from_mail(self, mail):
     id = self.config.get("user", "callsign") + \
         time.strftime("%m%d%Y%H%M%S") + \
         mail.get("Message-id", str(random.randint(0, 1000)))
     mid = platform.get_platform().filter_filename(id)
     ffn = os.path.join(self.config.form_store_dir(), _("Inbox"),
                        "%s.xml" % mid)
     try:
         form = create_form_from_mail(self.config, mail, ffn)
     except Exception, e:
         print "Failed to create form from mail: %s" % e
         return
コード例 #15
0
ファイル: subst.py プロジェクト: yanicky/d-rats
def load_subs():
    global sublist

    if sublist:
        return True

    f = platform.get_platform().config_file("subst.conf")
    if not f:
        return False

    sublist = SubstitutionList(f)

    return True
コード例 #16
0
ファイル: emailgw.py プロジェクト: coddingtonbear/d-rats
 def create_form_from_mail(self, mail):
     id = self.config.get("user", "callsign") + \
         time.strftime("%m%d%Y%H%M%S") + \
         mail.get("Message-id", str(random.randint(0, 1000)))
     mid = platform.get_platform().filter_filename(id)
     ffn = os.path.join(self.config.form_store_dir(),
                        _("Inbox"),
                        "%s.xml" % mid)
     try:
         form = create_form_from_mail(self.config, mail, ffn)
     except Exception, e:
         print "Failed to create form from mail: %s" % e
         return    
コード例 #17
0
ファイル: subst.py プロジェクト: coddingtonbear/d-rats
def load_subs():
    global sublist

    if sublist:
        return True

    f = platform.get_platform().config_file("subst.conf")
    if not f:
        return False

    sublist = SubstitutionList(f)

    return True
コード例 #18
0
ファイル: map_sources.py プロジェクト: yanicky/d-rats
    def __parse_level(self):
        url = "http://waterdata.usgs.gov/nwis/uv?format=rdb&period=1&site_no=%s" % self.__site

        p = platform.get_platform()
        try:
            fn, headers = p.retrieve_url(url)
            line = file(fn).readlines()[-1]
        except Exception, e:
            print "[NSGS] Failed to fetch info for site %s: %s" % (self.__site,
                                                                   e)
            self.set_comment("No data")
            self.set_timestamp(time.time())

            return
コード例 #19
0
ファイル: config.py プロジェクト: yanicky/d-rats
    def __init__(self, mainapp, safe=False):
        self.mainapp = mainapp
        self.safe = safe

        self.platform = platform.get_platform()
        try:
            self.default_port = self.platform.list_serial_ports()[0]
        except:
            self.default_port = ""

        self.tips = gtk.Tooltips()

        self._file = self.platform.config_file("d-rats.config")

        self.config = ConfigParser.ConfigParser()
        if not self.safe:
            self.load_config(self._file)
        self.fields = {}

        self.init_config()

        self.build_gui()
コード例 #20
0
def version_string():
    args = (CHIRP_VERSION,
            platform.get_platform().os_version_string(),
            sys.version.split()[0])
    return "CHIRP %s on %s (Python %s)" % args
コード例 #21
0
ファイル: logger.py プロジェクト: gitter-badger/chirp_fork
def version_string():
    args = (CHIRP_VERSION,
            platform.get_platform().os_version_string(),
            sys.version.split()[0])
    return "CHIRP %s on %s (Python %s)" % args
コード例 #22
0
#
# 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 sys

from optparse import OptionParser

if __name__ == "__main__":
    o = OptionParser()
    o.add_option("-s",
                 "--safe",
                 dest="safe",
                 action="store_true",
                 help="Safe mode (ignore configuration)")
    o.add_option("-c",
                 "--config",
                 dest="config",
                 help="Use alternate configuration directory")
    (opts, args) = o.parse_args()

    import platform

    if opts.config:
        platform.get_platform(opts.config)

    import mainapp

    app = mainapp.MainApp(safe=opts.safe)
    sys.exit(app.main())