Ejemplo n.º 1
0
def killRunningApps():
    workspace = NSWorkspace.sharedWorkspace()
    running_apps = workspace.runningApplications()
    for app in running_apps:
        match = re.match(regex, str(app.bundleIdentifier()))
        if match:
            _index = match.lastindex - 1
            exactBundleIDOrWildcard = re.sub(r"\(|\)", '', regex).split("|")[_index]
            
            # We call the takeaction method, with the additions below
            violationInfo = {
                "matchedRegex": exactBundleIDOrWildcard,
                "userName": NSProcessInfo.processInfo().userName(),
                "appName": app.localizedName(),
                "bundleIdentifier": app.bundleIdentifier(),
                "processIdentifier": app.processIdentifier(),
                "appPath...": 0
            }
           
            # Take action upon the app
            takeAction(violationInfo)
Ejemplo n.º 2
0
 def crawlWithSender_(self, sender):
     try:
         subs = self.subscriptions.recursive_subscriptions
         logger.debug('len(subs) = %d', len(subs))
         feeds_dict = {s.feed_uri: s for s in subs}
         cput_count = NSProcessInfo.processInfo().activeProcessorCount()
         logger.debug('len(feeds_dict) = %d', len(feeds_dict))
         for result in crawl(feeds_dict, cput_count):
             assert isinstance(result, CrawlResult)
             logger.info('Crawled %d entries from %s',
                         len(result.feed.entries), result.url)
             sub = feeds_dict[result.url]
             with self.stage:
                 if result.icon_url:
                     sub.icon_uri = result.icon_url
                     self.stage.subscriptions = self.subscriptions
                 self.stage.feeds[sub.feed_id] = result.feed
         logger.info('Finished crawling %d feeds', len(feeds_dict))
     except Exception as e:
         logger.exception(e)
     finally:
         self.pyobjc_performSelectorOnMainThread_withObject_(
             'stopRefreshWithSender:', sender
         )
Ejemplo n.º 3
0
 def __exit__(self, type, value, tb):
     NSProcessInfo.processInfo().enableAutomaticTermination_(self._reason)
Ejemplo n.º 4
0
 def __enter__(self):
     NSProcessInfo.processInfo().disableAutomaticTermination_(self._reason)
Ejemplo n.º 5
0
 def __exit__(self, type, value, tb):
     NSProcessInfo.processInfo().enableSuddenTermination()
Ejemplo n.º 6
0
 def __enter__(self):
     NSProcessInfo.processInfo().disableSuddenTermination()
Ejemplo n.º 7
0
        else:
            month_stop = month_start
    
        month_stop = (month_stop) % 12 + 1
    
        year_shift = 1 if (month_stop <= month_start) else 0
    
        start_date = datetime.date(year=now.year, month=month_start, day=1)
        stop_date = datetime.date(year=now.year+year_shift, month=month_stop, day=1)
    
        return start_date, stop_date


if __name__ == '__main__':

    os_version = NSProcessInfo.processInfo().operatingSystemVersionString()
    os_version = re.compile("Version (\d+\.\d+)\.\d+ .*").match(os_version).groups()[0]
    
    if float(os_version) < 10.6:
        print "icalreport needs Mac OS X 10.6 or later"
        sys.exit(1)
        
    from CalendarStore import *

    now = datetime.datetime.now()

    parser = OptionParser()

    parser.add_option("-c", help="Name of the calendar (mandatory)", dest="cal_name", metavar="NAME",)
    parser.add_option("-m", action="store", type="int", dest="month_start", metavar="MONTH",
                      help="Number of the month for which to report (default: current)")