[IronPython] Silverlight - animation from code

2008-03-19 Thread Michael Foord
Any idea why the following code does nothing? (root is the application 
root visual - the textblock becomes visible and 'starting' is printed at 
the right time - but the fint size doesn't change as I would expect from 
the Silverlight docs.)

from System import TimeSpan
from System.Windows import Duration
from System.Windows.Controls import TextBlock
from System.Windows.Media.Animation import (
DoubleAnimation, Storyboard
)

root.Children.Clear()
root.Resources.Clear()

t = TextBlock()
t.FontSize = 20
t.Text = 'Something Blue'
root.Children.Add(t)

sb = Storyboard()
duration = Duration(TimeSpan.FromSeconds(2))
a = DoubleAnimation()
a.Duration = duration
sb.Duration = duration
sb.Children.Add(a)

Storyboard.SetTarget(a, t)
Storyboard.SetTargetProperty(a, 'FontSize')
a.From = 20
a.To = 40

def anim(s, e):
print 'Starting'
sb.Begin()
   
t.MouseEnter += anim

root.Resources.Add(sb)



___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] NWSGI 0.1 released!

2008-03-19 Thread Jeff Hardy
Hi all,
I've finally built a binary version of NWSGI, which is much easier to
use than building it from source. It also includes a very simple
"Hello, World!" app to get started.

I've tested with some simple Paste applications, and CherryPy *almost*
works; if you hack around the bugs that it exposes, you'll get a nice
503 error page. With news that Django works, I'll give that a spin
when all of the bits are available.

Right now, it works best with IIS7 - deployment is dead simple.
Stories about IIS6 would be appreciated, as I don't have access to it.

Any and all comments are very much appreciated.

- Jeff Hardy
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] subprocess module

2008-03-19 Thread Jeff Hardy
Hi all,
Attached is a partial .NET implementation of the subprocess module.
There are currently a few limitations:

* Popen.communicate doesn't work
* Can't redirect stdin except for PIPE
* Can't redirect stderr to stdout (i.e. using stderr=subprocess.STDOUT)
* Can't redirect to a file descriptor
* univeral_newlines is not supported
* Command strings are flaky (lists work much better). Use shell=True
if using command strings.

Except for what's listed above, it passes most (about 2/3) of the
subprocess test cases.

The code is under the Ms-PL, except for list2cmdline which is under
the PSF license. I believe this is the correct way to do it (but
correct me if I'm wrong!).

Seo, what needs to be done to add this FePy?

- Jeff Hardy
# subprocess - A .NET implementation of the Python subprocess module
# 
# Copyright (c) Jeff Hardy 2007.
#
# This source code is subject to terms and conditions of the Microsoft Public 
License. A 
# copy of the license can be found at 
# 
http://www.microsoft.com/resources/sharedsource/licensingbasics/publiclicense.mspx.
 If 
# you cannot locate the Microsoft Public License, please send an email to 
# [EMAIL PROTECTED] By using this source code in any fashion, you are agreeing 
to be bound 
# by the terms of the Microsoft Public License.
#
# You must not remove this notice, or any other, from this software.
# 
# list2cmdline is taken from the Python 2.5 distribution, so the Python license 
applies.
# See http://www.python.org/2.4/license for details.

import sys, os
from System.Diagnostics import Process
from System.IO import MemoryStream

PIPE = -1
STDOUT = -2

class Popen(object):
""" Need documentation - copy from Python subprocess.py? """
def __init__(self, args, bufsize=0, executable=None, stdin=None, 
stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, 
cwd=None, env=None, universal_newlines=False, startupinfo=None, 
creationflags=0):
if preexec_fn:
raise ValueError("preexec_fn is not supported on Windows platforms")

if close_fds:
raise ValueError("close_fds is not supported on Windows platforms")

if universal_newlines:
raise ValueError("universal_newlines is not supported on .NET 
platforms")

if startupinfo:
raise ValueError("startupinfo is not supported on .NET platforms")

if creationflags:
raise ValueError("creationflags is not supported on .NET platforms")

if not isinstance(bufsize, (int, long)):
raise TypeError("bufsize must be an integer")

if stdin is not None and stdin != PIPE:
raise NotImplementedError("Cannont redirect stdin yet.")

if stderr == STDOUT:
raise NotImplementedError("Cannont redirect stderr to stdout yet.")

args = args if not isinstance(args, str) else args.split()
self.process = Process()
self.process.StartInfo.UseShellExecute = False

if not shell:
self.process.StartInfo.FileName = executable or args[0]
self.process.StartInfo.Arguments = list2cmdline(args[1:])
else:
self.process.StartInfo.FileName = executable or 
os.environ['COMSPEC']
self.process.StartInfo.Arguments = list2cmdline(['/C'] + args)

if env:
self.process.StartInfo.EnvironmentVariables.Clear()
for k, v in env.items():
self.process.StartInfo.EnvironmentVariables.Add(k, v)

self.process.StartInfo.WorkingDirectory = cwd or os.getcwd()

self.process.StartInfo.RedirectStandardInput = stdin is not None
self.process.StartInfo.RedirectStandardOutput = stdout is not None
self.process.StartInfo.RedirectStandardError = stderr is not None

combinedOutput = file(MemoryStream()) if stdout == PIPE and stderr == 
STDOUT else None
#~ print combinedOutput

if (stdout is not None and stdout != PIPE) or (stdout == PIPE and 
stderr == STDOUT):
self.process.OutputDataReceived += Redirector(combinedOutput or 
stdout, "stdout")

if stderr is not None and stderr != PIPE:
self.process.ErrorDataReceived += Redirector(combinedOutput or 
stderr, "stderr")

self.process.Start()
self.pid = self.process.Id

if (stdout is not None and stdout != PIPE) or (stdout == PIPE and 
stderr == STDOUT):
#~ print "stdout: start async"
self.process.BeginOutputReadLine()

if stderr is not None and stderr != PIPE:
#~ print "stderr: start async"
self.process.BeginErrorReadLine()

self.stdin = file(self.process.StandardInput.BaseStream) if stdin == 
PIPE else None
self.stdout = combinedOutput or 
(file(self.process.StandardOutput.BaseStream) if stdout == PIPE else None)
s

Re: [IronPython] 2.0B1 Hosting: Creating Python Types

2008-03-19 Thread Dino Viehland
In general you shouldn't need access to CodeContext for doing anything - unless 
you're writing an API which will be consumed by script code.  And the hosting 
APIs don't expose CodeContext instances so it can be challenging to get one 
without jumping through hoops.

Obviously there's a bunch of things people want to do that are Python specific 
and aren't covered by the DLR hosting APIs.  It'd be interesting to collect all 
of those things so that we can make sure we get all of the features that people 
want.

So far I think the interesting ones would include:
file
exception info
module access (built-ins at least and possibly Python modules)
type caller (which will actually going away, so no big deal there, but 
might be worth a discussion)

There's also some cleanup here for example creating ScriptScope's from the DLR 
doesn't give you a very usable Python module but we'll be fixing that.

Are there other things that jump out at people as missing?  Also, is there much 
interest in a 1.1 compatible hosting API or should we just expose this 
additional functionality?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Curt Hagenlocher
Sent: Wednesday, March 19, 2008 12:15 PM
To: Discussion of IronPython
Subject: Re: [IronPython] 2.0B1 Hosting: Creating Python Types

On Mon, Mar 17, 2008 at 5:26 PM, Dino Viehland
<[EMAIL PROTECTED]> wrote:
>
> CodeContext isn't actually internal but it's also not available to you via the
> hosting APIs.

Does this mean that we shouldn't be creating CodeContexts?  I'm using
the class "IronPython.Runtime.Operations.PythonTypeOps+TypeCaller" to
construct new objects from Python types.  This process requires a
CodeContext, which I'm currently building from scratch as needed.

(The same approach could be used with the PythonType
"IronPython.Runtime.Builtin.file" in order to build a Python file
object a little more efficiently.)

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] 2.0B1 Hosting: Creating Python Types

2008-03-19 Thread Curt Hagenlocher
On Wed, Mar 19, 2008 at 1:11 PM, Tarun Kapoor <[EMAIL PROTECTED]> wrote:
> If you need any help let me know. I am up for it.
> It is personally going to help me a lot, so I have vested interests in
> the project :)
> Is there a project webpage by the way, where I can read etc?

It's on CodePlex at http://www.codeplex.com/coils.  Feel free to
provide feedback or sign up :).

The existing code works against 2.0A8; it will updated for 2.0B1 by
the end of the week.

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] 2.0B1 Hosting: Creating Python Types

2008-03-19 Thread Tarun Kapoor
If you need any help let me know. I am up for it. 
It is personally going to help me a lot, so I have vested interests in
the project :)
Is there a project webpage by the way, where I can read etc?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Curt
Hagenlocher
Sent: Wednesday, March 19, 2008 2:55 PM
To: Discussion of IronPython
Subject: Re: [IronPython] 2.0B1 Hosting: Creating Python Types

On Wed, Mar 19, 2008 at 12:34 PM, Tarun Kapoor <[EMAIL PROTECTED]> wrote:
> Curt - at pycon, I heard that you are working on a CLR wrapper
project.
> Under which python code will be have automatically generated wrappers
> and that way they can called in C# more easily...
> Can you pls provide some details on how the project is going ?

I've just gotten back from vacation and will resume work on the
project once I recover from the twin devils of "jet lag" and "the
backlog".  I can't make any specific promises about progress right
now, but I'm definitely committed to making some :).

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Disclaimer

This e-mail and any attachments is confidential and intended solely for the use 
of the individual(s) to whom it is addressed. Any views or opinions presented 
are solely those of the author and do not necessarily represent those of 
Waterstone Capital Management, L.P and affiliates. If you are not the intended 
recipient, be advised that you have received this e-mail in error and that any 
use, dissemination, printing, forwarding or copying of this email is strictly 
prohibited. Please contact the sender if you have received this e-mail in 
error. You should also be aware that e-mails are susceptible to interference 
and you should not assume that the contents of this e-mail originated from the 
sender above or that they have been accurately reproduced in their original 
form. Waterstone Capital Management, L.P. and affiliates accepts no 
responsibility for information, or errors or omissions in this e-mail or use or 
misuse thereof. If in doubt, please verify the authenticity with the 
 sender.


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] 2.0B1 Hosting: Creating Python Types

2008-03-19 Thread Curt Hagenlocher
On Wed, Mar 19, 2008 at 12:34 PM, Tarun Kapoor <[EMAIL PROTECTED]> wrote:
> Curt - at pycon, I heard that you are working on a CLR wrapper project.
> Under which python code will be have automatically generated wrappers
> and that way they can called in C# more easily...
> Can you pls provide some details on how the project is going ?

I've just gotten back from vacation and will resume work on the
project once I recover from the twin devils of "jet lag" and "the
backlog".  I can't make any specific promises about progress right
now, but I'm definitely committed to making some :).

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] 2.0B1 Hosting: Creating Python Types

2008-03-19 Thread Tarun Kapoor
Curt - at pycon, I heard that you are working on a CLR wrapper project.
Under which python code will be have automatically generated wrappers
and that way they can called in C# more easily...
Can you pls provide some details on how the project is going ?
->>Sorry this is not related to the thread.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Curt
Hagenlocher
Sent: Wednesday, March 19, 2008 2:15 PM
To: Discussion of IronPython
Subject: Re: [IronPython] 2.0B1 Hosting: Creating Python Types

On Mon, Mar 17, 2008 at 5:26 PM, Dino Viehland
<[EMAIL PROTECTED]> wrote:
>
> CodeContext isn't actually internal but it's also not available to you
via the
> hosting APIs.

Does this mean that we shouldn't be creating CodeContexts?  I'm using
the class "IronPython.Runtime.Operations.PythonTypeOps+TypeCaller" to
construct new objects from Python types.  This process requires a
CodeContext, which I'm currently building from scratch as needed.

(The same approach could be used with the PythonType
"IronPython.Runtime.Builtin.file" in order to build a Python file
object a little more efficiently.)

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Disclaimer

This e-mail and any attachments is confidential and intended solely for the use 
of the individual(s) to whom it is addressed. Any views or opinions presented 
are solely those of the author and do not necessarily represent those of 
Waterstone Capital Management, L.P and affiliates. If you are not the intended 
recipient, be advised that you have received this e-mail in error and that any 
use, dissemination, printing, forwarding or copying of this email is strictly 
prohibited. Please contact the sender if you have received this e-mail in 
error. You should also be aware that e-mails are susceptible to interference 
and you should not assume that the contents of this e-mail originated from the 
sender above or that they have been accurately reproduced in their original 
form. Waterstone Capital Management, L.P. and affiliates accepts no 
responsibility for information, or errors or omissions in this e-mail or use or 
misuse thereof. If in doubt, please verify the authenticity with the 
 sender.


___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] 2.0B1 Hosting: Creating Python Types

2008-03-19 Thread Curt Hagenlocher
On Mon, Mar 17, 2008 at 5:26 PM, Dino Viehland
<[EMAIL PROTECTED]> wrote:
>
> CodeContext isn't actually internal but it's also not available to you via the
> hosting APIs.

Does this mean that we shouldn't be creating CodeContexts?  I'm using
the class "IronPython.Runtime.Operations.PythonTypeOps+TypeCaller" to
construct new objects from Python types.  This process requires a
CodeContext, which I'm currently building from scratch as needed.

(The same approach could be used with the PythonType
"IronPython.Runtime.Builtin.file" in order to build a Python file
object a little more efficiently.)

--
Curt Hagenlocher
[EMAIL PROTECTED]
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] [AVG SPAM] inheriting from "base" generic type

2008-03-19 Thread Jeff Hardy
Shameless plug: NWSGI (http://codeplex.com/NWSGI) will use IronPython
to run WSGI apps on IIS. It still needs a bit of work (and I'm still
in the process of updating it for B1) and a lot of documentation, but
it works for some simple cases.

If Dino can get Django working on IronPython, I'd be very interested
in trying it with NWSGI to really stess it.

-Jeff

On Wed, Mar 19, 2008 at 12:34 PM, Steve Holden <[EMAIL PROTECTED]> wrote:
> Miha:
>
> I understand that WSGI is available over IIS, so that would be one way
> to run Django. I'm too much of a noob in that environment to say whether
> it's been done yet, and if so by whom.
>
> regards
>  Steve
>
> Miha Valencic wrote:
> > Ahh, thanks for the answer. Quite a few issues to address I see. Do you
> > think it would make sense to run it in IIS somehow? (not via fastcgi
> > with CPython, but with IronPython). Is that even doable yet?
> >
> > Since I am no python expert, but I am rather coming from a C background
> > (and nowdays C# :)), the PEP 249 code you've written isn't very clear to
> > me. But, I will stufy it at least and learn that way.
> >
> > Are you also commiting to Django SVN the changes you make. or are you
> > running on your version?
> >
> > Miha
> >
> > On Mon, Mar 17, 2008 at 6:31 PM, Dino Viehland
> > <[EMAIL PROTECTED] > wrote:
> >
> > The short answer is yes, it runs.  The long answer is only 0.96.1
> > will run on IronPython 2.0 Beta 1 but there are some small issues:
> >
> >
> >
> > 
>
> >
> > ___
> > Users mailing list
> > Users@lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] 2.0B1 Hosting: Creating Python Types

2008-03-19 Thread Jeff Hardy
On Tue, Mar 18, 2008 at 9:49 PM, Dino Viehland
<[EMAIL PROTECTED]> wrote:
> Evaling __builtins__ should work (or import __builtin__ and then eval that).

Evaluate, not Execute :). Thanks, Dino.

The code, for anyone else who's interested, is:
private static object MakePythonFile(ScriptEngine engine,
System.IO.Stream stream)
{
return engine.Operations.Call(
engine.CreateScriptSourceFromString("__builtins__['file']")
.Compile().Evaluate(engine.CreateScope()),
stream);
}
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] [AVG SPAM] inheriting from "base" generic type

2008-03-19 Thread Steve Holden
Miha:

I understand that WSGI is available over IIS, so that would be one way 
to run Django. I'm too much of a noob in that environment to say whether 
it's been done yet, and if so by whom.

regards
  Steve

Miha Valencic wrote:
> Ahh, thanks for the answer. Quite a few issues to address I see. Do you 
> think it would make sense to run it in IIS somehow? (not via fastcgi 
> with CPython, but with IronPython). Is that even doable yet?
> 
> Since I am no python expert, but I am rather coming from a C background 
> (and nowdays C# :)), the PEP 249 code you've written isn't very clear to 
> me. But, I will stufy it at least and learn that way.
> 
> Are you also commiting to Django SVN the changes you make. or are you 
> running on your version?
> 
> Miha
> 
> On Mon, Mar 17, 2008 at 6:31 PM, Dino Viehland 
> <[EMAIL PROTECTED] > wrote:
> 
> The short answer is yes, it runs.  The long answer is only 0.96.1
> will run on IronPython 2.0 Beta 1 but there are some small issues:
> 
> 
> 
> 
> 
> ___
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com