예제 #1
0
 def parse_dict(d, default_timezone):
     return Event(EventTime.parse_dict(d['start'], default_timezone),
                  EventTime.parse_dict(d['end'], default_timezone),
                  d['summary'],
                  omap(lambda x: x.get('displayName'), (d.get('creator'))),
                  omap(lambda x: x.get('email'), (d.get('creator'))),
                  d.get('location'))
예제 #2
0
 def to_format(self, format_):
     return (
         format_
         .replace('%D', self.start_time.to_long_summary())
         .replace('%T', self.str_time_range())
         .replace('%S', self.summary)
         .replace('%C', oget(omap(lambda s: ' (%s)' % s, self.str_creator()), ''))
         .replace('%L', oget(omap(lambda s: ' @%s' % s, self.location), ''))
     )
예제 #3
0
 def get_opts(self):
     if self.port is None:
         return []
     xs = [
         '-Dcom.sun.management.jmxremote',
         omap(lambda x: '-Dcom.sun.management.jmxremote.port=%d' % x, self.port),
         omap(lambda b: '-Dcom.sun.management.jmxremote.ssl=%s' % JavaSetting.py_to_java_str(b), self.ssl),
         omap(lambda b: '-Dcom.sun.management.jmxremote.authenticate=%s' % JavaSetting.py_to_java_str(b), self.authenticate),
     ]
     return [x for x in xs if x is not None]
예제 #4
0
        def __init__(self, home, prefix=None, max_size=None, backup=None, preserve=None):
            # constraints
            assert backup is None or isinstance(backup, int), 'log.console.backup must be an integer'
            assert preserve is None or isinstance(backup, int), 'log.console.preserve must be an integer'

            CaseClass.__init__(
                self,
                ('prefix', omap(lambda p: normalize_path(p, home), prefix)),
                ('max_size', omap(DataSize, max_size)),
                ('backup', backup),
                ('preserve', preserve))
예제 #5
0
    def create_directories(self):
        dirs = [d for d in [
            omap(os.path.dirname, self.setting.log_setting.console.prefix),
            omap(os.path.dirname, self.setting.log_setting.gc.prefix),
            self.setting.log_setting.dump.prefix,
            omap(os.path.dirname, self.setting.log_setting.error.path),
        ] if d is not None]

        for d in dirs:
            if not os.path.exists(d):
                self._create_directory(d)
        return self
예제 #6
0
 def get_opts(self):
     xs = [
         omap(lambda s: '-Xms%s' % s, self.heap_min),
         omap(lambda s: '-Xmx%s' % s, self.heap_max),
         omap(lambda s: '-XX:PermSize=%s' % s, self.perm_min),
         omap(lambda s: '-XX:MaxPermSize=%s' % s, self.perm_max),
         omap(lambda s: '-XX:MetaspaceSize=%s' % s, self.metaspace_min),
         omap(lambda s: '-XX:MaxMetaspaceSize=%s' % s, self.metaspace_max),
         omap(lambda s: '-Xmn%s' % s, self.new_min),
         omap(lambda s: '-XX:MaxNewSize=%s' % s, self.new_max),
         omap(lambda x: '-XX:SurvivorRatio=%d' % x, self.survivor_ratio),
         omap(lambda x: '-XX:TargetSurvivorRatio=%d' % x, self.target_survivor_ratio),
     ]
     return [x for x in xs if x is not None]
예제 #7
0
    def to_format(self, format_):

        return (
            format_
            .replace('%I', self.event_id if not None else "")
            .replace('%Ds', self.start_time.to_long_summary())
            .replace('%De', self.end_time.to_long_summary())
            .replace('%D', self.start_time.to_long_summary())
            .replace('%Ts', self.start_time.to_short_summary() if self.start_time.has_time else "00:00")
            .replace('%Te', self.end_time.to_short_summary() if self.end_time.has_time else "00:00")
            .replace('%T', self.str_time_range())
            .replace('%S', self.summary)
            .replace('%C', oget(omap(lambda s: '(%s)' % s, self.str_creator()), ''))
            .replace('%L', oget(omap(lambda s: '@%s' % s, self.location), ''))
        )
예제 #8
0
 def get_opts(self):
     if self.port is None:
         return []
     xs = [
         '-Dcom.sun.management.jmxremote',
         omap(lambda x: '-Dcom.sun.management.jmxremote.port=%d' % x,
              self.port),
         omap(
             lambda b: '-Dcom.sun.management.jmxremote.ssl=%s' %
             JavaSetting.py_to_java_str(b), self.ssl),
         omap(
             lambda b: '-Dcom.sun.management.jmxremote.authenticate=%s'
             % JavaSetting.py_to_java_str(b), self.authenticate),
     ]
     return [x for x in xs if x is not None]
예제 #9
0
 def to_dict(self):
     if self.has_time:
         d = {'dateTime': self.datetime_tz.isoformat()}
     else:
         d = {'date': self.datetime_tz.date().isoformat()}
     d.update(oget(omap(lambda tz: {'timeZone': str(tz)}, self.datetime_tz.tzinfo), {}))
     return d
예제 #10
0
 def to_dict(self):
     if self.has_time:
         d = {'dateTime': self.datetime_tz.isoformat()}
     else:
         d = {'date': self.datetime_tz.date().isoformat()}
     d.update(oget(omap(lambda tz: {'timeZone': str(tz)}, self.datetime_tz.tzinfo), {}))
     return d
예제 #11
0
        def __init__(self,
                     home,
                     prefix=None,
                     max_size=None,
                     backup=None,
                     preserve=None):
            # constraints
            assert backup is None or isinstance(
                backup, int), 'log.console.backup must be an integer'
            assert preserve is None or isinstance(
                backup, int), 'log.console.preserve must be an integer'

            CaseClass.__init__(
                self,
                ('prefix', omap(lambda p: normalize_path(p, home), prefix)),
                ('max_size', omap(DataSize, max_size)), ('backup', backup),
                ('preserve', preserve))
예제 #12
0
 def get_opts(self):
     xs = [
         omap(lambda s: '-Xms%s' % s, self.heap_min),
         omap(lambda s: '-Xmx%s' % s, self.heap_max),
         omap(lambda s: '-XX:PermSize=%s' % s, self.perm_min),
         omap(lambda s: '-XX:MaxPermSize=%s' % s, self.perm_max),
         omap(lambda s: '-XX:MetaspaceSize=%s' % s, self.metaspace_min),
         omap(lambda s: '-XX:MaxMetaspaceSize=%s' % s,
              self.metaspace_max),
         omap(lambda s: '-Xmn%s' % s, self.new_min),
         omap(lambda s: '-XX:MaxNewSize=%s' % s, self.new_max),
         omap(lambda x: '-XX:SurvivorRatio=%d' % x,
              self.survivor_ratio),
         omap(lambda x: '-XX:TargetSurvivorRatio=%d' % x,
              self.target_survivor_ratio),
     ]
     return [x for x in xs if x is not None]
예제 #13
0
    def _make_output(self, events):
        """Make the output string from an event list."""

        # group by event date
        f = lambda e: e.start_time.to_date()
        evs = ['\n'.join(e.to_format(self.format) for e in g) for k, g in itertools.groupby(events, f)]
        sep = (omap(lambda s: '\n' + s, self.separator) or '') + '\n'

        # make the result string
        return sep.join(evs)
예제 #14
0
    def __init__(self, name=None, home=None, jar=None, entry_point=None, command=None, pid_file=None):
        # constraints
        assert name is not None, 'app.name is required'
        assert home is not None, 'app.home is required'
        assert os.path.isabs(home), 'app.home must be an absolute path'
        assert (jar is None) != (command is None), 'Either app.jar or app.command but not both must be given'
        assert jar is not None or entry_point is None, 'app.entry_point must be used with app.jar'

        normalize = lambda p: normalize_path(p, home)

        CaseClass.__init__(
            self,
            ('name', name),
            ('home', home),
            ('jar', omap(normalize, jar)),
            ('entry_point', entry_point),
            ('command', omap(normalize, command)),
            ('pid_file', omap(normalize, pid_file))
        )
예제 #15
0
    def _make_output(self, events):
        """Make the output string from an event list."""

        # group by event date
        f = lambda e: e.start_time.to_date()
        evs = [
            '\n'.join(e.to_format(self.format) for e in g)
            for k, g in itertools.groupby(events, f)
        ]
        sep = (omap(lambda s: '\n' + s, self.separator) or '') + '\n'

        # make the result string
        return sep.join(evs)
예제 #16
0
    def to_dict(self):
        r = {'summary': self.summary, 'start': self.start_time.to_dict(), 'end': self.end_time.to_dict()}

        d = {}
        omap(lambda x: d.update({'displayName': x}), self.creator_name)
        omap(lambda x: d.update({'email': x}), self.creator_email)
        if d:
            r.update({'creator': d})

        omap(lambda x: r.update({'location': x}), self.location)
        return r
예제 #17
0
    def __init__(self, config_path=None, work_dir=None, root_menu=None, encoding=None, lang=None, width=None,
                 clear_cache=False, cache_dir=EVAL_CACHE_DIR, pid_dir=COMMAND_PID_DIR,
                 stdin=None, stdout=None, stderr=None, getch_enabled=True, source_enabled=True):
        is_url = Loader.is_url(config_path)
        work_dir = omap(lambda s: to_unicode(s, encoding), self._search_work_dir(work_dir, config_path, is_url))

        CaseClass.__init__(self,
                           ('config_path', config_path),
                           ('work_dir', work_dir),
                           ('root_menu', oget(root_menu, {})),
                           ('encoding', encoding),
                           ('lang', self._find_lang(lang)),
                           ('width', width),
                           ('clear_cache', clear_cache),
                           ('cache_dir', cache_dir),
                           ('pid_dir', pid_dir),
                           ('stdin', oget(stdin, sys.stdin)),
                           ('stdout', oget(stdout, sys.stdout)),
                           ('stderr', oget(stderr, sys.stderr)),
                           ('getch_enabled', getch_enabled),
                           ('source_enabled', source_enabled)
                           )
예제 #18
0
 def str_creator(self):
     return omap(lambda s: '%s' % s, oget(self.creator_name, self.creator_email))
예제 #19
0
 def __init__(self, home, path=None):
     CaseClass.__init__(self, ('path', omap(lambda p: normalize_path(p, home), path)))
예제 #20
0
 def __init__(self, home, prefix=None):
     CaseClass.__init__(self, ('prefix', omap(lambda p: normalize_path(p, home), prefix)))
예제 #21
0
 def get_path(self, now):
     return omap(lambda p: p + now.strftime('_%Y%m%d_%H%M%S.log'), self.prefix)
예제 #22
0
 def str_time_range(self):
     s = ozip(self.start_time.to_short_summary(), self.end_time.to_short_summary())
     return oget(omap('-'.join, s), MSG_ALL_DAY)
예제 #23
0
 def str_creator(self):
     return omap(lambda s: '%s' % s, oget(self.creator_name, self.creator_email))
예제 #24
0
 def test_omap(self):
     self.assertEqual(omap(lambda x: x + 1, 123), 124)
     self.assertEqual(omap(lambda x: x + 1, None), None)
예제 #25
0
 def str_time_range(self):
     s = ozip(self.start_time.to_short_summary(), self.end_time.to_short_summary())
     return oget(omap('-'.join, s), MSG_ALL_DAY)
예제 #26
0
 def __init__(self, home, path=None):
     CaseClass.__init__(
         self, ('path', omap(lambda p: normalize_path(p, home), path)))
예제 #27
0
 def __init__(self, home, prefix=None):
     CaseClass.__init__(
         self,
         ('prefix', omap(lambda p: normalize_path(p, home), prefix)))
예제 #28
0
 def get_path(self, now):
     return omap(lambda p: p + now.strftime('_%Y%m%d_%H%M%S.log'),
                 self.prefix)