[Script]Serverstruktur

06/14/2013 23:15 'oShet#16
Quote:
Originally Posted by CrystalPrime View Post
#Moverequest bitte oder Closen
Denn ich glaube weniger das dieser Dr. Anonymous die Erlaubnis dafür
hat das zu releasen, außerdem ist es ein ganz kleines Script welches
wenn schon hier hin gehört:
[Only registered and activated users can see links. Click Here To Register...]
Und WER hat bitteschön irg.eine erlaubnis hier eigentum von GF4D/Ymir zu releasen? Niemand!

Edit:
What does "SERVER_KEY" do at the configs?
Was bringt "SERVER_KEY" in der Config datei?
06/14/2013 23:24 #dynastie#17
Quote:
Originally Posted by 'oShet View Post
Und WER hat bitteschön irg.eine erlaubnis hier eigentum von GF4D/Ymir zu releasen? Niemand!

Edit:
What does "SERVER_KEY" do at the configs?
Was bringt "SERVER_KEY" in der Config datei?
Bei Gameforge oder YMIR interessiert das leider keinen, aber wenn etwas von WoM (tim) oder so kommt, ist natürlich jeder voll dagegen und muss dann den Leuten in den Arsch kriechen.

Guten Abend.
06/14/2013 23:26 'oShet#18
Quote:
Originally Posted by #dynastie View Post
Bei Gameforge oder YMIR interessiert das leider keinen, aber wenn etwas von WoM (tim) oder so kommt, ist natürlich jeder voll dagegen und muss dann den Leuten in den Arsch kriechen.

Guten Abend.
Metin2 halt :D Alles kleine arschkriecher die nichts alleine auf die reihe bekommen
06/14/2013 23:39 <Dafuq>#19
Script ist schön geschrieben, paar der Zeilen sind für den Coding Style zwar nicht ganz optimal, aber immer noch in Ordnung.
Bei den Formatting Options ist es vllt. der Übersichtlichkeit her hinzugefügt worden, ist aber unnötig, sofern es sowieso nicht geändert werden würde.
Mehr kann man an dem Script nicht aussetzen, ist klar und verständlich gecodet, entspricht bis auf paar langen Zeilen dem kompletten Style Guide und Kommentierung ist durch die sinnvollen Namensbezeichnungen auch nicht unbedingt nötig.

Würde mich mal interessieren, wer das ganze geschrieben hat, ist auf jeden Fall ein sauberes Script.

Ach ja, wer das ganze nutzen möchte, das Script basiert auf 2.x Basis, ist für 3.x inkompatibel, müsstet ihr dafür minimal umschreiben, hat sich nicht ganz so viel geändert.

MfG <Dafuq>
06/14/2013 23:46 Pаylasici#20
Quote:
Originally Posted by <Dafuq> View Post
Script ist schön geschrieben, paar der Zeilen sind für den Coding Style zwar nicht ganz optimal, aber immer noch in Ordnung.
Bei den Formatting Options ist es vllt. der Übersichtlichkeit her hinzugefügt worden, ist aber unnötig, sofern es sowieso nicht geändert werden würde.
Mehr kann man an dem Script nicht aussetzen, ist klar und verständlich gecodet, entspricht bis auf paar langen Zeilen dem kompletten Style Guide und Kommentierung ist durch die sinnvollen Namensbezeichnungen auch nicht unbedingt nötig.

Würde mich mal interessieren, wer das ganze geschrieben hat, ist auf jeden Fall ein sauberes Script.

MfG <Dafuq>
tim66613
06/14/2013 23:58 thespeedyy#21
und wie benutze ich das?
06/15/2013 00:01 Pаylasici#22
Quote:
Originally Posted by thespeedyy View Post
und wie benutze ich das?
Python für dein OS installieren, kleine Veränderungen durchnehmen und ausführen.
06/15/2013 11:49 <Dafuq>#23
hab minimale Veränderungen gemacht(Autor namens tim66613 hinzugefügt, encoding hinzugefügt, main function verändert) und das ganze mal kommentiert, nachdem hier einige noch die Fragen hatten was das ganze denn überhaupt machen würde.

PHP Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

from itertools import chain
import sys
import os
import shutil

__author__ 
'tim66613'

# Simple class holding the info from the locale/*/map/index file
class AllowedMapList:
    
def __init__(self):
        
# initializes name_to_index_map dictionary ( dict() is equal to {} )
        
self.name_to_index_map dict()
    
    
"""
    used for loading our index file
    """
    
def LoadMapIndexFile(selffilename):
        
# using the opening process of our index file as file var 
        
with open(filename) as file:
            
# run loop for every line in the opened file
            
for line in file:
                
# using spaces to split the map index and the map name apart(strip to remove f.e. \n) 
                
indexname line.strip().split()
                
                
# if our map name is already in the dict, append it to our array
                
if name in self.name_to_index_map:
                    
self.name_to_index_map[name].append(index)
                
# else create sub variable in our dictionary and add an single element array ( [index] )
                
else:
                    
self.name_to_index_map[name] = [index]
    
    
"""
    used for getting our index vars from the created dictionary
    """
    
def GetIndexListFromNameList(selfnames):
        
# not as easy to explain as the other script lines, here equal, but more inefficient script to explain it:
        # initializing our tmp variable(empty array)
        #tmp = []
        # run the loop for every element in our names array
        #for name in names:
        # because the map can have multiple index numbers, using " ".join to get them in plain text and append them to our array
        #    tmp.append(" ".join(self.name_to_index_map[name]))
        # return our created array
        #return(tmp)        
        
return [" ".join(self.name_to_index_map[name]) for name in names]

class 
TreeCreator:
    
"""
    basic init function, automatically called if class is called
    """
    
def __init__(self):
        
# using our class we explained before as variable
        
self.allowed_map_list AllowedMapList()
        
# initialize every other variable(defined later)
        
self.output_path None
        self
.template_path None
        self
.config_dict None
        
    
""" 
    used for our configuration script
    """
    
def LoadConfigScript(selffilename):
        
# again equal to {}
        
self.config_dict dict()
        
# execute our configuration file, to set variables, in this case the file "trunk_server_conf.py" and safe it in self.config_dict
        
execfile(filenameself.config_dict)
        
        
# define the variables we initialized in the init function with the dict we created from the configuration file
        
self.output_path self.config_dict["kOutputPath"]
        
self.template_path self.config_dict["kTemplatePath"]
        
        
# loading the index file(until now it was barely an unused class)
        
self.allowed_map_list.LoadMapIndexFile(self.config_dict["kMapIndexPath"])
        
        
# copy process
        
try:
            
shutil.copytree(self.template_path "/base"self.output_path)
        
# exception if the path already exists, so remove it(can fail here again if python is using the path already(unhandled exception in this case))
        
except os.error:
            print 
"Output directory already exists. Erasing..."
            
# remove path, exception case is missing
            
shutil.rmtree(self.output_path)
            
# create again
            
shutil.copytree(self.template_path "/base"self.output_path)
        
        
# Channels
        # run for every channel in our config_dict, the channel config var
        # only used for writing the basic files, you should be able to know what this part is writing ;)
        
for channel in self.config_dict["kChannelConfig"]:
            
os.mkdir(self.output_path "/" channel)
            
            for 
game in self.config_dict["kChannelConfig"][channel]:
                
shutil.copytree(self.template_path "/game"self.output_path "/" channel "/" game)
                
merged_conf dict(chain(self.config_dict["kBaseConfig"]["game"].iteritems(), self.config_dict["kChannelConfig"][channel][game].iteritems()))
                
open(self.output_path "/" channel "/" game "/CONFIG""wb").write(self.GetConfigString(merged_confself.ProcessGameConfigEntry))

        
# Special configs
        
merged_conf dict(chain(self.config_dict["kBaseConfig"]["game"].iteritems(), self.config_dict["kBaseConfig"]["game99"].iteritems()))
        
open(self.output_path "/game99/CONFIG""wb").write(self.GetConfigString(merged_confself.ProcessGameConfigEntry))

        
open(self.output_path "/auth/CONFIG""wb").write(self.GetConfigString(self.config_dict["kBaseConfig"]["auth"], self.ProcessGameConfigEntry))
        
open(self.output_path "/db/conf.txt""wb").write(self.GetConfigString(self.config_dict["kBaseConfig"]["db"], self.ProcessDbConfigEntry))

        
# Script files
        
install_sh open(self.output_path "/install.sh""ab")
        
run_sh open(self.output_path "/run.sh""ab")
        
shutdown_sh open(self.output_path "/shutdown.sh""ab")
        
clear_sh open(self.output_path "/clear.sh""ab")

        for 
channel in self.config_dict["kChannelConfig"]:
            for 
game in self.config_dict["kChannelConfig"][channel]:
                
install_sh.write("cd $ROOT/%s && sh install.sh\n" % (channel "/" game))
                
run_sh.write("echo \"Starting %s\"\ncd $ROOT/%s && sh run.sh\n\n" % (channel "/" gamechannel "/" game))
                
shutdown_sh.write("echo \"Stopping %s\"\ncd $ROOT/%s && sh shutdown.sh\n\n" % (channel "/" gamechannel "/" game))
                
clear_sh.write("cd $ROOT/%s && sh clear.sh\n" % (channel "/" game))

        
install_sh.write("cd $ROOT/%s && sh install.sh\n" % ("game99"))
        
run_sh.write("echo \"Starting %s\"\ncd $ROOT/%s && sh run.sh\nsleep 2\n\n" % ("game99""game99"))
        
shutdown_sh.write("echo \"Stopping %s\"\ncd $ROOT/%s && sh shutdown.sh\n\n" % ("game99""game99"))
        
shutdown_sh.write("echo \"Stopping %s\"\ncd $ROOT/%s && sh shutdown.sh\n\n" % ("db""db"))
        
clear_sh.write("cd $ROOT/%s && sh clear.sh\n" % ("game99"))
        
    
"""
    function used to get the configuration as string
    """
    
def GetConfigString(self, list, fn):
        
# create array from our list with every key
        
conf_entries = [fn(key, list[key]) for key in list]
        
# sort it based on the key(kv.split(":")[0].lower()), basic sort
        
conf_entries.sort(key lambda kvkv.split(":")[0].lower())
        
# return as plain text, using "\n".join(conf_entries)
        
return '\n'.join(conf_entries)
        
    
"""
    function used to get the proper db config entry
    """
    
def ProcessDbConfigEntry(selfkeyvalue):
        
# simple if check, if value(!= 0, != False, != null, != "", != " ") and not key == "ITEM_ID_RANGE
        
if not value or (value.find(' ') != -and key != "ITEM_ID_RANGE"):
            return 
key " = \"" value "\""
        
# else case
        
else:
            return 
key " = " value

    
"""
    function used to get the proper game config entry
    """
    
def ProcessGameConfigEntry(selfkeyvalue):
        
# check the key
        
if key == "MAP_ALLOW":
            
# check if value != > 32(max number of allowed maps for every core)
            
if len(value) > 32:
                print 
value
                
print "MAP_ALLOW has too many values!"
            
else:
                
# using the other function the get a plain text string using for our map allow
                
return "MAP_ALLOW: " " ".join(self.allowed_map_list.GetIndexListFromNameList(value))
        else:
            
# else case
            
return key ": " value

"""
main function
"""
def main():
    
creator TreeCreator()
    
creator.LoadConfigScript("trunk_server_conf.py")

if 
__name__ == "__main__":
    
main() 
06/15/2013 17:46 thespeedyy#24
und wie starte und führe ich das script aus
06/15/2013 18:11 .CHHorny#25
Quote:
Originally Posted by thespeedyy View Post
und wie starte und führe ich das script aus
Das ist nicht dein Ernst? :facepalm:

Script wurde ohne Erlaubnis Public gemacht, es wurde noch erklärt und noch "verbessert" und du Fragst das noch? Payla hats doch gesagt wie es geht.
06/15/2013 18:30 thespeedyy#26
ich hab ja python installiert nur kann ich die make.py nicht ausführen
06/15/2013 18:39 .CHHorny#27
Liegt daran das es keine gibt? :facepalm:
06/15/2013 18:47 thespeedyy#28
wie soll ich es dann ausführen?!
06/15/2013 23:11 'oShet#29
Quote:
Originally Posted by thespeedyy View Post
wie soll ich es dann ausführen?!
Du kannst damit eh nichts anfangen also lass es einfach...
Begib dich an kleine dinge und wenn du mehr ahnung hast dann komm wieder in diesen thread