<commit_before>"""A util script used on daryl's laptop to switch 'iemdb' /etc/hosts entry

172.16.31.10 iemdb iemdb2
#127.0.0.1 iemdb iemdb2

"""
import sys
import tempfile
import os


def main():
    if len(sys.argv) == 1:
        print('Usage: python set_iemdb_etc_hosts.py <local|remote>')
        return
    ip = '127.0.0.1' if (sys.argv[1] == 'local') else '172.16.31.10'
    data = open('/etc/hosts').read()
    result = []
    for line in data.split("\n"):
        if line.find("iemdb iemdb2") > 0:
            line = "%s iemdb iemdb2" % (ip, )
            print("Setting iemdb to ip: %s" % (ip, ))
        result.append(line)
    (tmpfd, tmpfn) = tempfile.mkstemp()
    os.write(tmpfd, '\n'.join(result))
    os.close(tmpfd)
    os.rename(tmpfn, '/etc/hosts')


if __name__ == '__main__':
    main()<commit_msg>correct /etc/hosts file perms to 0644 on util script<commit_after>"""A util script used on daryl's laptop to switch 'iemdb' /etc/hosts entry

172.16.31.10 iemdb iemdb2
#127.0.0.1 iemdb iemdb2

"""
import sys
import tempfile
import os


def main():
    if len(sys.argv) == 1:
        print('Usage: python set_iemdb_etc_hosts.py <local|remote>')
        return
    ip = '127.0.0.1' if (sys.argv[1] == 'local') else '172.16.31.10'
    data = open('/etc/hosts').read()
    result = []
    for line in data.split("\n"):
        if line.find("iemdb iemdb2") > 0:
            line = "%s iemdb iemdb2" % (ip, )
            print("Setting iemdb to ip: %s" % (ip, ))
        result.append(line)
    (tmpfd, tmpfn) = tempfile.mkstemp()
    os.write(tmpfd, '\n'.join(result))
    os.close(tmpfd)
    os.rename(tmpfn, '/etc/hosts')
    os.chmod('/etc/hosts', 0644)


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.17192982456140352, 'fraction_numerical': 0.047953216374269005, 'mean_word_length': 2.655982905982906, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, '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': '3611437', 'n_tokens_mistral': 714, 'n_tokens_neox': 661, 'n_words': 161}