summaryrefslogtreecommitdiff
path: root/licensecheck/serverdata.py
blob: 0235c982b7ab7df5ee88a67e1c362e7cc5598b9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/bin/env python2.7
# -*- coding: utf8 -*-
#
# Copyright (C) 2018  TMW-2
# Author: Jesusalva

import os

sv="../../server-data/npc/"
erp=[]
err=0

print("Checking license info for second level NPCs")

for mp in os.listdir(sv):

    # we actually should read scripts and imports, but this script is designed to be dumb
    if "." in mp or mp == "dev":
        continue

    for script in os.listdir(sv+mp):
        if (not ".txt" in script) and (not ".conf" in script):
            continue
        if ("~" in script) or ("#" in script) or ("mapflags.txt" in script):
            continue

        a=open(sv+mp+'/'+script, 'r')
        ok=False
        for line in a:
            if 'tmw2 script' in line.lower() or 'tmw-2 script' in line.lower() or 'tmw 2 script' in line.lower() or 'tmw2/lof script' in line.lower() or 'This file is generated automatically' in line:
                ok=True
                break

        a.close()
        if not ok:
            erp.append(mp+'/'+script)
            err+=1

if len(erp) > 0:
    print("-----------------------------------------------------------------------")

for i in sorted(erp):
    print(i)

print("-----------------------------------------------------------------------")
print("Serverdata license check result")
print("Errors: %d" % (err))
#if err > 0:
#    os.exit(1)