<commit_before>! Copyright (C) 2008, 2009 <NAME>, <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel namespaces sequences splitting system accessors
math.functions make io io.files io.pathnames io.directories
io.directories.hierarchy io.launcher io.encodings.utf8 prettyprint
combinators.short-circuit parser combinators math calendar
calendar.format arrays mason.config locals debugger fry
continuations strings io.sockets ;
IN: mason.common

ERROR: no-host-name ;

: short-host-name ( -- string )
    host-name "." split1 drop [ no-host-name ] unless* ;

SYMBOL: current-git-id

: short-running-process ( command -- )
    #! Give network operations and shell commands at most
    #! 15 minutes to complete, to catch hangs.
    >process 15 minutes >>timeout try-output-process ;

HOOK: really-delete-tree os ( path -- )

M: windows really-delete-tree
    #! Workaround: Cygwin GIT creates read-only files for
    #! some reason.
    [ { "chmod" "ug+rw" "-R" } swap absolute-path suffix short-running-process ]
    [ delete-tree ]
    bi ;

M: unix really-delete-tree delete-tree ;

: retry ( n quot -- )
    [ iota ] dip
    '[ drop @ f ] attempt-all drop ; inline

:: upload-safely ( local username host remote -- )
    remote ".incomplete" append :> temp
    { username "@" host ":" temp } concat :> scp-remote
    scp-command get :> scp
    ssh-command get :> ssh
    5 [ { scp local scp-remote } short-running-process ] retry
    5 [ { ssh host "-l" username "mv" temp remote } short-running-process ] retry ;

: eval-file ( file -- obj )
    dup utf8 file-lines parse-fresh
    [ "Empty file: " swap append throw ] [ nip first ] if-empty ;

: to-file ( object file -- ) utf8 [ . ] with-file-writer ;<commit_msg>mason.common: increase timeout because Windows is damn slow<commit_after>! Copyright (C) 2008, 2009 <NAME>, <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel namespaces sequences splitting system accessors
math.functions make io io.files io.pathnames io.directories
io.directories.hierarchy io.launcher io.encodings.utf8 prettyprint
combinators.short-circuit parser combinators math calendar
calendar.format arrays mason.config locals debugger fry
continuations strings io.sockets ;
IN: mason.common

ERROR: no-host-name ;

: short-host-name ( -- string )
    host-name "." split1 drop [ no-host-name ] unless* ;

SYMBOL: current-git-id

: short-running-process ( command -- )
    #! Give network operations and shell commands at most
    #! 30 minutes to complete, to catch hangs.
    >process 30 minutes >>timeout try-output-process ;

HOOK: really-delete-tree os ( path -- )

M: windows really-delete-tree
    #! Workaround: Cygwin GIT creates read-only files for
    #! some reason.
    [ { "chmod" "ug+rw" "-R" } swap absolute-path suffix short-running-process ]
    [ delete-tree ]
    bi ;

M: unix really-delete-tree delete-tree ;

: retry ( n quot -- )
    [ iota ] dip
    '[ drop @ f ] attempt-all drop ; inline

:: upload-safely ( local username host remote -- )
    remote ".incomplete" append :> temp
    { username "@" host ":" temp } concat :> scp-remote
    scp-command get :> scp
    ssh-command get :> ssh
    5 [ { scp local scp-remote } short-running-process ] retry
    5 [ { ssh host "-l" username "mv" temp remote } short-running-process ] retry ;

: eval-file ( file -- obj )
    dup utf8 file-lines parse-fresh
    [ "Empty file: " swap append throw ] [ nip first ] if-empty ;

: to-file ( object file -- ) utf8 [ . ] with-file-writer ;
{'fraction_non_alphanumeric': 0.12104072398190045, 'fraction_numerical': 0.010180995475113122, 'mean_word_length': 3.127187864644107, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 21, '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': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4418108', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1097, 'n_words': 353}