summaryrefslogtreecommitdiff
path: root/licensecheck/serverdata.py
blob: 9c68edb814d91ac3c358aca78e2db8bb60d5da5e (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /usr/bin/env python2.7
# -*- coding: utf8 -*-
#
# Copyright (C) 2018  TMW-2
# Author: Jesusalva

# Bad command:
# ls --recursive --hyperlink=always --format=single-column ../../server-data/npc/|grep txt

import os
erp=[]

# Clear previous NPC list
import subprocess
try:
    subprocess.call("rm npcs.txt", shell=True)
except:
    pass

# Generate NPC list
subprocess.call("find ../../server-data/npc/ txt > npcs.txt", shell=True)
npcs=open("npcs.txt", "r")

# Begin
print("Checking license info for NPCs (this excludes _npcs and mapflags)")

for mpa in npcs:
    mp=mpa.replace('\n','')
    # Skip files prefixed with _ or called mapflags
    if "mapflag" in mp:
      continue
    if "_import" in mp:
      continue
    if "_warps" in mp:
      continue
    if "_mobs" in mp:
      continue
    # Skip bad files
    if not '.txt' in mp:
      continue
    # Skip certain folders
    if  "/dev/" in mp or "/00000SAVE/" in mp:
      continue

    a=open(mp, 'r')
    print("Verify %s" % mp)
    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)

npcs.close()
if len(erp) > 0:
    print("-----------------------------------------------------------------------")

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

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