diff --git a/.gitignore b/.gitignore
index 2bc6e0d..dc1c293 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
RECOVER*.fla
GraphicExport.app/
*.p12
+*.airi
diff --git a/.gitignore b/.gitignore
index 2bc6e0d..dc1c293 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
RECOVER*.fla
GraphicExport.app/
*.p12
+*.airi
diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml
index e210f14..5144634 100755
--- a/GraphicExport-app.xml
+++ b/GraphicExport-app.xml
@@ -16,7 +16,7 @@
Japanese App name goes here
-->
-
+
GraphicExport
1.0
GraphicExport
diff --git a/.gitignore b/.gitignore
index 2bc6e0d..dc1c293 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
RECOVER*.fla
GraphicExport.app/
*.p12
+*.airi
diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml
index e210f14..5144634 100755
--- a/GraphicExport-app.xml
+++ b/GraphicExport-app.xml
@@ -16,7 +16,7 @@
Japanese App name goes here
-->
-
+
GraphicExport
1.0
GraphicExport
diff --git a/GraphicExport.as b/GraphicExport.as
index 161026f..c3586c2 100644
--- a/GraphicExport.as
+++ b/GraphicExport.as
@@ -51,7 +51,6 @@
var UILayer:MovieClip = new MovieClip();
public static var ISLOCAL = true;
public static var wrapper:Socket = null;
- private static var lastData = "";
public function GraphicExport()
{
@@ -110,26 +109,15 @@
private function WrapperData(e:ProgressEvent)
{
- var data:String = wrapper.readUTFBytes(wrapper.bytesAvailable);
- for (var i = 0; i < data.length; i++)
- {
- var c = data.charAt(i);
- if (c == "\0")
- {
- if (lastData != "") DispatchCommand(lastData);
- lastData = "";
- }
- else
- {
- lastData += c;
- }
- }
+ var data:String = wrapper.readUTF();
+ DispatchCommand(data);
+ _strace("done");
}
private function DispatchCommand(command)
{
Log("Wrapper Command: " + command);
- _strace("exeucting: " + command);
+ _strace("executing: " + command);
}
private function ConnectWrapper(port)
diff --git a/.gitignore b/.gitignore
index 2bc6e0d..dc1c293 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
RECOVER*.fla
GraphicExport.app/
*.p12
+*.airi
diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml
index e210f14..5144634 100755
--- a/GraphicExport-app.xml
+++ b/GraphicExport-app.xml
@@ -16,7 +16,7 @@
Japanese App name goes here
-->
-
+
GraphicExport
1.0
GraphicExport
diff --git a/GraphicExport.as b/GraphicExport.as
index 161026f..c3586c2 100644
--- a/GraphicExport.as
+++ b/GraphicExport.as
@@ -51,7 +51,6 @@
var UILayer:MovieClip = new MovieClip();
public static var ISLOCAL = true;
public static var wrapper:Socket = null;
- private static var lastData = "";
public function GraphicExport()
{
@@ -110,26 +109,15 @@
private function WrapperData(e:ProgressEvent)
{
- var data:String = wrapper.readUTFBytes(wrapper.bytesAvailable);
- for (var i = 0; i < data.length; i++)
- {
- var c = data.charAt(i);
- if (c == "\0")
- {
- if (lastData != "") DispatchCommand(lastData);
- lastData = "";
- }
- else
- {
- lastData += c;
- }
- }
+ var data:String = wrapper.readUTF();
+ DispatchCommand(data);
+ _strace("done");
}
private function DispatchCommand(command)
{
Log("Wrapper Command: " + command);
- _strace("exeucting: " + command);
+ _strace("executing: " + command);
}
private function ConnectWrapper(port)
diff --git a/GraphicExport.exe b/GraphicExport.exe
index 51690f8..0f1c480 100755
--- a/GraphicExport.exe
+++ b/GraphicExport.exe
Binary files differ
diff --git a/.gitignore b/.gitignore
index 2bc6e0d..dc1c293 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
RECOVER*.fla
GraphicExport.app/
*.p12
+*.airi
diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml
index e210f14..5144634 100755
--- a/GraphicExport-app.xml
+++ b/GraphicExport-app.xml
@@ -16,7 +16,7 @@
Japanese App name goes here
-->
-
+
GraphicExport
1.0
GraphicExport
diff --git a/GraphicExport.as b/GraphicExport.as
index 161026f..c3586c2 100644
--- a/GraphicExport.as
+++ b/GraphicExport.as
@@ -51,7 +51,6 @@
var UILayer:MovieClip = new MovieClip();
public static var ISLOCAL = true;
public static var wrapper:Socket = null;
- private static var lastData = "";
public function GraphicExport()
{
@@ -110,26 +109,15 @@
private function WrapperData(e:ProgressEvent)
{
- var data:String = wrapper.readUTFBytes(wrapper.bytesAvailable);
- for (var i = 0; i < data.length; i++)
- {
- var c = data.charAt(i);
- if (c == "\0")
- {
- if (lastData != "") DispatchCommand(lastData);
- lastData = "";
- }
- else
- {
- lastData += c;
- }
- }
+ var data:String = wrapper.readUTF();
+ DispatchCommand(data);
+ _strace("done");
}
private function DispatchCommand(command)
{
Log("Wrapper Command: " + command);
- _strace("exeucting: " + command);
+ _strace("executing: " + command);
}
private function ConnectWrapper(port)
diff --git a/GraphicExport.exe b/GraphicExport.exe
index 51690f8..0f1c480 100755
--- a/GraphicExport.exe
+++ b/GraphicExport.exe
Binary files differ
diff --git a/GraphicExport.swf b/GraphicExport.swf
index e6508d8..285d862 100644
--- a/GraphicExport.swf
+++ b/GraphicExport.swf
Binary files differ
diff --git a/.gitignore b/.gitignore
index 2bc6e0d..dc1c293 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
RECOVER*.fla
GraphicExport.app/
*.p12
+*.airi
diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml
index e210f14..5144634 100755
--- a/GraphicExport-app.xml
+++ b/GraphicExport-app.xml
@@ -16,7 +16,7 @@
Japanese App name goes here
-->
-
+
GraphicExport
1.0
GraphicExport
diff --git a/GraphicExport.as b/GraphicExport.as
index 161026f..c3586c2 100644
--- a/GraphicExport.as
+++ b/GraphicExport.as
@@ -51,7 +51,6 @@
var UILayer:MovieClip = new MovieClip();
public static var ISLOCAL = true;
public static var wrapper:Socket = null;
- private static var lastData = "";
public function GraphicExport()
{
@@ -110,26 +109,15 @@
private function WrapperData(e:ProgressEvent)
{
- var data:String = wrapper.readUTFBytes(wrapper.bytesAvailable);
- for (var i = 0; i < data.length; i++)
- {
- var c = data.charAt(i);
- if (c == "\0")
- {
- if (lastData != "") DispatchCommand(lastData);
- lastData = "";
- }
- else
- {
- lastData += c;
- }
- }
+ var data:String = wrapper.readUTF();
+ DispatchCommand(data);
+ _strace("done");
}
private function DispatchCommand(command)
{
Log("Wrapper Command: " + command);
- _strace("exeucting: " + command);
+ _strace("executing: " + command);
}
private function ConnectWrapper(port)
diff --git a/GraphicExport.exe b/GraphicExport.exe
index 51690f8..0f1c480 100755
--- a/GraphicExport.exe
+++ b/GraphicExport.exe
Binary files differ
diff --git a/GraphicExport.swf b/GraphicExport.swf
index e6508d8..285d862 100644
--- a/GraphicExport.swf
+++ b/GraphicExport.swf
Binary files differ
diff --git a/exporter.py b/exporter.py
index aa6d6a0..f223b1d 100755
--- a/exporter.py
+++ b/exporter.py
@@ -8,6 +8,9 @@
import json
import traceback
import shlex
+import struct
+import threading
+import Queue
class ArgParser:
def __init__(self):
@@ -87,7 +90,9 @@
usage()
sys.exit(2)
+from_stdin = False
if "-" in args["input"]:
+ from_stdin = True
if len(args["input"]) > 1 or "type" in args or "scale" in args:
print "If reading from stdin ('-') is specified, no other input may be given"
usage()
@@ -97,24 +102,45 @@
usage()
sys.exit(0)
-port = 7890
+port = args["port"] if "port" in args else 7890
s = socket.socket()
s.bind(("localhost", port))
exporter_args = [os.getcwd() + "/GraphicExport.exe"]
-# exporter_args = [os.getcwd() + "/GraphicExport.app/GraphicExport.exe", str(port)]
+#exporter_args = [os.getcwd() + "/GraphicExport.app/GraphicExport.exe", str(port)]
g = subprocess.Popen(exporter_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
s.settimeout(0.5)
s.listen(0)
+stdin_q = Queue.Queue()
+
+def get_stdin():
+ while True:
+ line = sys.stdin.readline()
+ stdin_q.put(line)
+ if line == "":
+ return
+
+def make_base_cmd(args):
+ return {"type": args["type"] if "type" in args else 1, \
+ "scale": args["scale"] if "scale" in args else 1}
+
+def send_cmd(conn, base_cmd, in_file):
+ cmd = dict(base_cmd)
+ cmd["input"] = in_file
+ data = json.dumps(cmd)
+ datalen = struct.pack(">H", len(data))
+ conn.send(datalen)
+ conn.send(data)
+
conn = None
while conn is None and g.returncode is None:
try:
(conn, _) = s.accept()
except socket.timeout, e:
- pass
+ pass
except e:
print e
s.close()
@@ -125,23 +151,49 @@
if conn:
conn.setblocking(False)
- conn.send("EXPORT|" + "|".join(sys.argv[1:]) + "\0")
+ if from_stdin:
+ reader = threading.Thread(target=get_stdin)
+ reader.daemon = True
+ reader.start()
+ else:
+ base_cmd = make_base_cmd(args)
+ for i in args["input"]:
+ send_cmd(conn, base_cmd, i)
+quit = False
while g.returncode is None:
try:
d = conn.recv(4096)
if len(d):
- sys.stdout.write(d)
- sys.stdout.flush()
+ if d.strip() == "done":
+ quit = True
+ else:
+ sys.stdout.write(d)
+ sys.stdout.flush()
except socket.error, e:
if e.args[0] == errno.EWOULDBLOCK or e.args[0] == errno.EAGAIN:
pass
else:
print e
- conn.close()
- s.close()
- g.wait()
- sys.exit(1)
+ quit = True
+ if not quit and from_stdin and stdin_q.qsize():
+ line = stdin_q.get()
+ if line == "":
+ quit = True
+ else:
+ parts = shlex.split(line)
+ (err, line_args) = ArgParser.parse_args(parts)
+ if err is not None:
+ print err
+ else:
+ base_cmd = make_base_cmd(line_args)
+ for i in line_args["input"]:
+ send_cmd(conn, base_cmd, i)
+ if quit:
+ conn.close()
+ s.close()
+ g.kill()
+ sys.exit(1)
g.poll()
if (conn):