This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
kazagistar's profile picture

External file copier for linux

Started by kazagistar, 30 April 2012 - 08:33 PM
kazagistar #1
Posted 30 April 2012 - 10:33 PM
I didn't want to copy all my programs onto the turtles in the tekkit server by hand, and there is no way to transfer them to my server other then copying them in. So I made a simple python utility that copies them in place. You just have to run it with the list of files to transfer as a parameters, then select your minecraft game already opened to a computercraft terminal, and it will start typing (after a 5 second delay) and write them all in. Just dont select anything else while it is running (I will have it target a specific window once I can figure out how to do this). It requires libxdo to be installed, just apt-get install libxdo.

#!/usr/bin/python
import time,sys
from ctypes import *
key_press_delay = 5000
editor_wait_delay = 0.2
xdo=cdll.LoadLibrary("libxdo.so.2")
xdo_context=xdo.xdo_new(None)
def typeout(string):
	xdo.xdo_type(xdo_context, 0, string, key_press_delay)
def typekeys(keysyms):
	for key in keysyms:
xdo.xdo_keysequence(xdo_context, 0, key, key_press_delay)
time.sleep(editor_wait_delay)
def copyfile(filename):
	f = open(filename)
	data = f.read()
	typeout("rm "+filename+"\nedit "+filename+"\n")
	time.sleep(editor_wait_delay)
	typeout(data)
	typekeys(["ctrl","Return","ctrl","Left","Return"])
if __name__ == "__main__":
	print "Select minecraft window now!"
	time.sleep(5)
	for filename in sys.argv[1:]:
		copyfile(filename)
Onionnion #2
Posted 30 April 2012 - 11:01 PM
Nice util!
Luanub #3
Posted 01 May 2012 - 04:02 AM
Since this is python with some slight modifications you could run this on a windows box as well. Very handy.
kazagistar #4
Posted 01 May 2012 - 08:46 AM
No, sorry, this would not run on windows at all. The command (xdo=cdll.LoadLibrary("libxdo.so.2")) loads a local C library into python called libxdo, which is specific to the X11 windowing system and is not cross-platform, and repacing it with something in windows would require replacing almost the whole program. I just don't want people to get confused, sorry.
DrEckenbecker #5
Posted 04 May 2012 - 04:36 AM
Excellent program!
atomhell #6
Posted 25 August 2012 - 04:09 PM
Yeah, I never realized how lucky I was to have filesystem access to the Tekkit server for file transfer.

Now I am playing on another server with no file access, and I have no idea how to push updates to the /rom/ folder without nagging the server owner…

I hope to find a web-based solution.