Register for your free account! | Forgot your password?

You last visited: Today at 23:46

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[TuT] Python Scripts kompilieren

Discussion on [TuT] Python Scripts kompilieren within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #1
 
Pacifista''s Avatar
 
elite*gold: 0
Join Date: Apr 2013
Posts: 186
Received Thanks: 155
[TuT] Python Scripts kompilieren

Vorab: Ich weiß nicht ob es so einen Thread schon gibt, falls doch, bitte löschen.

Important: Falls Ihr *.py Dateien aus dem Metin2 Client verwendet solltet ihr aufjedenfall Python 2.2 installieren und verwenden!

Hallo Community,

ich dachte mir ich zeige euch heute mal wie Ihr eure Python Scripts kompilieren könnt. (In unserem Fall einfach mal eine *.py Datei in eurem Metin2 Client)

Für das Tutorial benötigt Ihr folgendes:
  • Python (ich verwende Python 3.3.1)
  • Einzelne *.py Scripts
Zum Tutorial:

Ihr installiert euch wie oben erwähnt Python, geht in den Pfad indem Ihr es installiert habt und legt am besten einen neuen Ordner an. (z.B 'my_own_scripts')
Dort legt Ihr nun alle *.py Dateien rein, die Ihr kompiliert haben wollt.

Nun geht Ihr zurück in das (in meinem Falle) Python33 Verzeichnis und startet von dort aus die 'Python.exe'.

Nun öffnet sich eine Konsole, in der Ihr folgendes eintragt:
Code:
Falls Ihr compileall verwenden wollt:

import compileall

Falls Ihr py_compile verwenden wollt:

import py_compile
Erklärung:
Dieser Befehl importiert 'compileall.py' oder 'py_compile' und ermöglicht es uns Befehle aus diesem Script zu verwenden.

Danach kommt dieser Befehl:
Code:
Falls Ihr compileall verwenden wollt:

compileall.compile_dir('my_own_scripts', force=True)

Falls Ihr py_compile verwenden wollt:

py_compile.compile("my_own_scripts\dateiname.py")
Erklärung:
COMPILEALL: Dieser Befehl listet alle *.py Dateien im Ordner 'my_own_scripts' im Python33 Verzeichnis auf und kompiliert Sie im Pfad: 'my_own_scripts\__pycache__\'.
PY_COMPILE: Dieser Befehl kompiliert eine einzelne *.py Datei im ausgewählten Verzeichnis.

Falls Ihr dass erledigt habt wird in eurem Ordner 'my_own_scripts' ein neuer Ordner namens '__pycache__' angelegt, indem sich nun die kompilierten nicht mehr *.py sondern *.pyc (Python Compiled) Dateien befinden, diese können falls Ihr Python 2.2 verwendet habt, normal in eurem Client weiterverwendet werden und halten zumindest Kinder von dem Inhalt eurer Python Scripts ab.

Ich hoffe ich konnte euch helfen.

#Added Python 2.2, VT bitte selbst ausführen.
Attached Files
File Type: zip Python-2.2.zip (6.58 MB, 224 views)
Pacifista' is offline  
Thanks
4 Users
Old 05/07/2013, 01:55   #2
 
elite*gold: 139
Join Date: Sep 2010
Posts: 583
Received Thanks: 546
Du weißt schon wenn du das mit Py 3.3 Kompilierst,dass Metin2 das nicht lesen kann weil Py 2.2 das anders kompiliert? Außerdem würde ich py_compile benutzen. Ich kann keinen Zusammenhang zu Metin2 hier erkennen.
.XXShuzZzle is offline  
Thanks
1 User
Old 05/07/2013, 01:56   #3
 
Pacifista''s Avatar
 
elite*gold: 0
Join Date: Apr 2013
Posts: 186
Received Thanks: 155
Habe Metin2 doch nur als Beispiel genommen. ._.
#Hab noch mal 'ne Anmerkung dazu geschrieben, zufrieden? :3
Pacifista' is offline  
Old 05/07/2013, 02:05   #4
 
elite*gold: 21
Join Date: Oct 2012
Posts: 374
Received Thanks: 524
mit compilieren von .py keine ahnungx xD

wo bekomm ich py dingens für 2.2 her?

grüße
Analyze™ is offline  
Old 05/07/2013, 02:22   #5
 
Pacifista''s Avatar
 
elite*gold: 0
Join Date: Apr 2013
Posts: 186
Received Thanks: 155
Einfach mal in Google nach 'Python GetIt' suchen, da ich nicht weiß ob ich hier einen Link posten darf.
Pacifista' is offline  
Old 05/07/2013, 03:29   #6
 
elite*gold: 21
Join Date: Oct 2012
Posts: 374
Received Thanks: 524
Quote:
Originally Posted by Pacifista' View Post
Einfach mal in Google nach 'Python GetIt' suchen, da ich nicht weiß ob ich hier einen Link posten darf.
so dann packst noch decompiling mit rein in den startpost und dann ist es komplett
Analyze™ is offline  
Old 05/07/2013, 03:35   #7
 
Pacifista''s Avatar
 
elite*gold: 0
Join Date: Apr 2013
Posts: 186
Received Thanks: 155
Geh kacken.

Soll zum Schutz und nicht zur Zerstörung dienen. xD
Pacifista' is offline  
Old 05/07/2013, 06:28   #8
 
lollo_9_1's Avatar
 
elite*gold: 100
Join Date: Jun 2009
Posts: 168
Received Thanks: 711
This "tutorial" is partially/quite wrong.
  1. Metin2 uses python2.2.1, u cannot import a pyc module compiled in other python version (only with python2.2.*, python2.2.2/2.2.3 allowed)
  2. Every .py, when imported, generates the relative .pyc (or .pyo if u start python.exe with -O option) in byte-code and runned.
  3. Therefore, in agreement with the above points, u can create a relative pyc/pyo file simply importing them
  4. Without a program of dubious origin:
    • Download python2.2 (official website)
    • Start python.exe (with -O option if u want a pyo file instead of a pyc, -O=optimization) and:
      Code:
      #first way A (compile and import XXX.py file)
      try:
      	import yourmodule #create a .pyc/o file from .py if .pyc/o file not exists
      except ImportError:
      	pass
      #first way B (compile and import XXX.py file)
      import __builtin__
      try:
      	__builtin.__import__("yourmodule") #create a .pyc/o file from .py if .pyc/o file not exists
      except ImportError:
      	pass
      #second way (all recursive py files in XXX directory and subdirectories)
      import compileall
      compileall.compile_dir("lib/", force=1) #in python2.2 bool not exists, metin uses TRUE and FALSE constants with the relative values 1 and 0, in python u can use a / instead of \ to indicate paths
      #third way (compile XXX file)
      import py_compile
      py_compile.compile("yourmodule.py")


Now, to load in client (ymir has rewritten __import__ function) ur pyc file u must use marshal module like this:
Code:
# system.py
import marshal
marshal.loads(pack_file("yourmodule.pyc",'rb').read()[8:])#first 8 byte=magic
#newmodule = _process_result(marshal.loads(pack_file(filename,'rb').read()[8:]),name)
lollo_9_1 is offline  
Thanks
4 Users
Old 05/07/2013, 07:19   #9
 
Pacifista''s Avatar
 
elite*gold: 0
Join Date: Apr 2013
Posts: 186
Received Thanks: 155
Thanks for the help, I'm sorry if I described something wrong.
I have only taken Metin2 as an example.

Sorry for my bad english.
Pacifista' is offline  
Old 05/07/2013, 07:32   #10
 
JachuPL's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 50
Received Thanks: 83
and how to uncompile compiled scripts (if that's possible)?
JachuPL is offline  
Old 05/07/2013, 08:27   #11
 
Pacifista''s Avatar
 
elite*gold: 0
Join Date: Apr 2013
Posts: 186
Received Thanks: 155
Yes, it's possible.
Pacifista' is offline  
Old 05/07/2013, 09:08   #12
 
xP3NG3Rx's Avatar
 
elite*gold: 50
Join Date: May 2011
Posts: 270
Received Thanks: 991
Google>python22 decompyle/decompile
Or here is my upload:

How2 setup: Use your brain.

Example for decompile:
Code:
from decompyle import decompyle_file as dec
s=open('decompiled.py','w')
dec('compiledfile.pyc', s,0,0)
xP3NG3Rx is offline  
Thanks
3 Users
Old 05/07/2013, 09:09   #13
 
Prince43™'s Avatar
 
elite*gold: 0
Join Date: Jan 2013
Posts: 489
Received Thanks: 495
Quote:
Originally Posted by .XXShuzZzle View Post
Du weißt schon wenn du das mit Py 3.3 Kompilierst,dass Metin2 das nicht lesen kann weil Py 2.2 das anders kompiliert? Außerdem würde ich py_compile benutzen. Ich kann keinen Zusammenhang zu Metin2 hier erkennen.

Mein Hasi, in deinem satz steht schon die Lösung Nachdenken----Komplieren = Lösung <3

B2T: Schöne sache, jedoch gibt es da noch paar haaken.



Kind Regards

Prince43™
Prince43™ is offline  
Thanks
1 User
Old 05/07/2013, 11:17   #14
 
elite*gold: 6
Join Date: Nov 2011
Posts: 73
Received Thanks: 88
Und was ist mit mir ich hab dir geholfen ;D
xNe0nx3 is offline  
Old 05/07/2013, 12:03   #15
 
elite*gold: 139
Join Date: Sep 2010
Posts: 583
Received Thanks: 546
Quote:
Originally Posted by JachuPL View Post
and how to uncompile compiled scripts (if that's possible)?
yes but not to 100% because it is still byte code
.XXShuzZzle is offline  
Reply

Tags
kompilieren, metin2, py, pyc, pythonscript


Similar Threads Similar Threads
[LazyRelease] Log python npc scripts from TQ!
07/12/2014 - CO2 PServer Guides & Releases - 43 Replies
Ok so I posted about this ages ago but realized after being msg'd on youtube that I've never actually posted the code to do this... As many of you know, I never bothered adding npc scripts for well... any npcs in the hellmouth source... THIS WILL ONLY LOG NPC SPAWN LOCATIONS AND THE FIRST PAGE OF TEXT/OPTIONS WHEN YOU TALK TO THEM!!! I've also been trying to encourage people to use the damn external python scripts but so far they haven't taken much of an interest... well here's...
Metin2 - Python - Wie Python Hacks verschlüsseln und Server überprüfen (GF/PServe)
09/23/2012 - Metin2 - 2 Replies
Ich wollte fragen, wie man Python Hacks am besten Verschlüsselt ? und wie man feststellen kann ob man auf einem GF / Pserver spielt. ?
[SERVICE]Python-Scripts Erstellen :)
02/17/2012 - Metin2 Trading - 0 Replies
Heyho, In diesem Thread bitte ich meine Python kenntnisse für euch an ^^ Ich erfülle alle wünsche (soweit wie möglich) Kleinere Scripts mache ich auch Kostenlos :) Der Preisvariert je nachdem wie lange es dauert und wie umfangreich das scripts sein soll. Beispiele:
Automaton Scripts python
12/17/2010 - Flyff Private Server - 1 Replies
hi Leute hi ******** ich war schon lange nicht mehr on und nun habe ich wieder lust und zeit Fame zu spielen ich suche wieder scripts in python geschrieben für automaton 1.3 pls hab schon SuFu und gegooglet leider nichts gefunden weis auch nimmer wie die scripts heisen. PM me oder post
PYTHON SCRIPTS AUSFÜHREN
03/12/2010 - Metin2 - 2 Replies
kennt jmd in metin2 n py script, das ein anderes script ausführt, oder weiß jmd wie man das macht??



All times are GMT +1. The time now is 23:47.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.