<commit_before>request             = require 'request-json'
fs                  = require 'fs'
slugify             = require 'cozy-slug'
{exec}              = require 'child_process'
async               = require 'async'
cozydb              = require 'cozydb'
log                 = require('printit')
prefix: "applications"

Application         = require '../models/application'
NotificationsHelper = require 'cozy-notifications-helper'
localizationManager = require '../helpers/localization_manager'
manager             = require('../lib/paas').get()
{Manifest}          = require '../lib/manifest'
market              = require '../lib/market'
autostop            = require '../lib/autostop'
icons               = require '../lib/icon'

# Small hack to ensure that an user doesn't try to start an application twice
# at the same time. We store there the ID of apps which are already started.
# IDs are the keys, values are all equal to true.
startedApplications = {}

# Helpers

# Remove a notification after an update
removeAppUpdateNotification = (app) ->
    notifier = new NotificationsHelper 'home'
    messageKey = 'update available notification'
    message = localizationManager.t messageKey, appName: app.displayName
    notificationSlug = "home_update_notification_app_#{app.name}"
    notifier.destroy notificationSlug, (err) ->
        log.error err if err?

sendError = (res, err, code=500) ->
    err ?=
        stack:   null
        message: localizationManager.t "server error"

    console.log "Sending error to client :"
    console.log err.stack

    res.send code,<commit_msg>Remove dead code<commit_after>request             = require 'request-json'
fs                  = require 'fs'
slugify             = require 'cozy-slug'
{exec}              = require 'child_process'
async               = require 'async'
cozydb              = require 'cozydb'
log                 = require('printit')
prefix: "applications"

Application         = require '../models/application'
NotificationsHelper = require 'cozy-notifications-helper'
localizationManager = require '../helpers/localization_manager'
manager             = require('../lib/paas').get()
{Manifest}          = require '../lib/manifest'
market              = require '../lib/market'
autostop            = require '../lib/autostop'
icons               = require '../lib/icon'

# Small hack to ensure that an user doesn't try to start an application twice
# at the same time. We store there the ID of apps which are already started.
# IDs are the keys, values are all equal to true.
startedApplications = {}

# Helpers

# Remove a notification after an update
removeAppUpdateNotification = (app) ->
    notifier = new NotificationsHelper 'home'
    notificationSlug = "home_update_notification_app_#{app.name}"
    notifier.destroy notificationSlug, (err) ->
        log.error err if err?

sendError = (res, err, code=500) ->
    err ?=
        stack:   null
        message: localizationManager.t "server error"

    console.log "Sending error to client :"
    console.log err.stack

    res.send code,
{'fraction_non_alphanumeric': 0.10204744881377965, 'fraction_numerical': 0.0019499512512187196, 'mean_word_length': 2.489795918367347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4026871', 'n_tokens_mistral': 826, 'n_tokens_neox': 812, 'n_words': 264}