Coder Social home page Coder Social logo

Comments (2)

mojca avatar mojca commented on July 19, 2024

The above mentioned problem has been addressed by replacing

controls = [map(eval,a.replace("controls","").split("and")) for a in tokens if a.startswith("controls")]

with

[eval(a.replace("controls", "").split("and")) for a in tokens if a.startswith("controls")]

in GUI/xasyFile.py.

The next problem seems to be fin.readline() from asyfyThread in xasy2asy.py which doesn't seem to be able to read anything. This might be related to some problems in Popen or os.fdopen, but it's not yet clear what exactly is going on.

Below is a standalone example to reproduce the problem:

#!/usr/bin/env python

import sys,os,signal,subprocess,threading,tempfile

AsyTempDir=tempfile.mkdtemp(prefix="asy_")+os.sep
print("AsyTempDir: '{}'".format(AsyTempDir))

(rx,wx) = os.pipe()
(ra,wa) = os.pipe()
cmd = ['asy',"-noV","-multiline","-q", "-o"+AsyTempDir,"-inpipe="+str(rx),"-outpipe="+str(wa)]
print(cmd)

# when close_fds=True, it hangs on 2.7 as well
quickAsy=subprocess.Popen(cmd,close_fds=False)
fout=os.fdopen(wx,'w')
fin=os.fdopen(ra,'r')

#######
fout.write("reset;\n")
fout.write("initXasyMode();\n")
fout.write("atexit(null);\n")
fout.write('xformStack.push((0, 0, 1, 0, 0, 1));\n')
fout.write('label(Label("test",(0, 0),rgb(0,0,0)+0.5,align=SE));\n')
fout.write('deconstruct(1.000000);\n')
fout.flush()

text = fin.readline()
print("    readline:")
print("'{}'".format(text))
fout.write("exit;\n");

fin.close()
fout.close()

The parameter close_fds=False doesn't seem to make any difference in Python 3 (it's set to False in Python 2 and to True in Python 3 by default), but if I set it to True, then Python 2 hangs as well.

from asymptote.

mojca avatar mojca commented on July 19, 2024

I fixed the problem with pipes thanks to some great answers from MacPorters and will describe more details soon.

John, is the second replacement for oneLiner OK?

Old code:

oneLiner = "".join(split(join(pathStrLines)))

New code:

# oneLiner = "".join(" ".join(pathStrLines).split()) # this is literal translation
oneLiner = "".join(pathStrLines).replace(" ", "") # this is probably more straightforward

from asymptote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.