<commit_before>//
//  AppDelegate.swift
//  Blockstack
//
//  Created by <NAME> on 2/26/17.
//  Copyright © 2017 Blockstack. All rights reserved.
//

import Cocoa
import Sparkle

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
    
    
    let productionModePortalPort = 8888
    let developmentModePortalPort = 3000
    let corsProxyPort = 1337
    let coreProxyPort = 6270
    let portalAuthenticationPath = "/auth?authRequest="
    
    var statusItem : NSStatusItem = NSStatusItem()
    
    var isDevModeEnabled : Bool = false
    
    var isShutdown : Bool = false
    
    let keychainServiceName = "blockstack-core-wallet-password"
    let keychainAccountName = "blockstack-core"
    
    let coreArchive = "blockstack-venv.tar.gz"
    let coreConfigFileRelativePath = "config/client.ini"
    let coreVenvDirectory = "blockstack-venv"
    let extractCoreVenvToPath = "/tmp"
    let portalRunDirectory = "portal"
    
    let portalProxyProcess = Process()
    let corsProxyProcess = Process()
    let coreProcess = Process()
    
    let sparkleUpdater = SUUpdater.init(for: Bundle.main)

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        NSLog("applicationDidFinishLaunching: \(blockstackDataURL())")
        
        let appleEventManager = NSAppleEventManager.shared()
        appleEventManager.setEventHandler(self, andSelector: #selector(handleGetURLEvent), forEventClass: UInt32(kInternetEventClass), andEventID: UInt32(kAEGetURL))
        
        statusItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)
        
        if let button = statusItem.button {
            button.image = NSImage(named: "MenuBar")
            button.alternateImage = NSImage(named: "MenuBarDark")
            button.action = #selector(statusItemClick)
        }
        
        let walletPassword = createOrRetrieveCoreWalletPassword()
        
        // using the wallet password as Core API password is intentional
        startPortalProxy(complete: {
            let delayInSeconds = 0.5
            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delayInSeconds) {
                self.openPortal(path: "/")<commit_msg>try out macOS unified logging api #375<commit_after>//
//  AppDelegate.swift
//  Blockstack
//
//  Created by <NAME> on 2/26/17.
//  Copyright © 2017 Blockstack. All rights reserved.
//

import Cocoa
import Sparkle
import os.log

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
    
    
    let productionModePortalPort = 8888
    let developmentModePortalPort = 3000
    let corsProxyPort = 1337
    let coreProxyPort = 6270
    let portalAuthenticationPath = "/auth?authRequest="
    
    var statusItem : NSStatusItem = NSStatusItem()
    
    var isDevModeEnabled : Bool = false
    
    var isShutdown : Bool = false
    
    let keychainServiceName = "blockstack-core-wallet-password"
    let keychainAccountName = "blockstack-core"
    
    let coreArchive = "blockstack-venv.tar.gz"
    let coreConfigFileRelativePath = "config/client.ini"
    let coreVenvDirectory = "blockstack-venv"
    let extractCoreVenvToPath = "/tmp"
    let portalRunDirectory = "portal"
    
    let portalProxyProcess = Process()
    let corsProxyProcess = Process()
    let coreProcess = Process()
    
    let sparkleUpdater = SUUpdater.init(for: Bundle.main)
    
    let log = OSLog(subsystem: "org.blockstack.mac.Blockstack", category: "Default")
    
    func applicationDidFinishLaunching(_ aNotification: Notification) {
        os_log("applicationDidFinishLaunching: %{public}@", log: log, type: .default, blockstackDataURL().absoluteString)
        
        let appleEventManager = NSAppleEventManager.shared()
        appleEventManager.setEventHandler(self, andSelector: #selector(handleGetURLEvent), forEventClass: UInt32(kInternetEventClass), andEventID: UInt32(kAEGetURL))
        
        statusItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)
        
        if let button = statusItem.button {
            button.image = NSImage(named: "MenuBar")
            button.alternateImage = NSImage(named: "MenuBarDark")
            button.action = #selector(statusItemClick)
        }
        
        let walletPassword = createOrRetrieveCoreWalletPassword()
        
        // using the wallet password as Core API password is intentional
        startPortalProxy(complete: {
            let delayInSeconds = 0.5
            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delayInSeconds) {
                self.openPortal(path: "/")
{'fraction_non_alphanumeric': 0.08607979184735473, 'fraction_numerical': 0.01409366869037294, 'mean_word_length': 3.0008673026886385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '525375', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1292, 'n_words': 293}