Re: A 35mm film camera represented in Python object

2021-03-18 Thread D.M. Procida
Eli the Bearded <*@eli.users.panix.com> wrote:

> In comp.lang.python,
> D.M. Procida  wrote:
> > Eli the Bearded <*@eli.users.panix.com> wrote:
> >> I see you don't even attempt to tackle ISO outside of
> >> supported range (and I have no idea how the camera itself deals with
> >> that). Is the camera sensing the ISO from the film roll (so won't work
> >> with hand rolled film cartridges)? Is there a setting on the camera to
> >> manually specify that? (I don't think so.)
> > The camera's film speed setting (it's old enough that it's ASA rather
> > than ISO) is set manually. If you try to set an illegal value, there's a
> > setter decorator that raises a NonExistentFilmSpeed exception.
> 
> I can see what the code does, I'm asking what the camera does and do you
> plan to work that into your code? Maybe it only works for ISO 1600 in
> manual mode, but works.

The code does what the camera allows - the camera has a ring with film
speeds of 25, 50, 100, 200, 400, 800 marked on it; those are the values
you can select (in fact there are two unmarked steps in between each of
those, but I've yet to build those in).

Internally, moving the film speed ring slides contacts along a variable
resistor, which is part of the metering system circuitry. It could be
that the range of the resistor or the theoretical range of the circuit
is beyond the settable values, but I can't work that out from the
circuit diagram.

Daniele
-- 
https://mail.python.org/mailman/listinfo/python-list


[SQLAlchemy] Struggling with association_proxy

2021-03-18 Thread Robert Latest via Python-list
I'm trying to implement a many-to-many relationship that associates Baskets
with Items via an association object called Link which holds the quantity of
each item. I've done that in SQLAlchemy in a very pedestrian way, such as when
I want to have six eggs in a basket:

1. Find ID of Item with name 'egg'
2. See if there is an association object with the egg ID and the basket ID
3a. if yes, set its quantity to 6
3b if no, create it with quantity 6 and add it to the items colletion in basket

The association_proxy documentation suggests that this could be done elegantly
in such a way that I could simply write

basket.contents['egg'] = 6

and be done with it. I've tried to follow the documentation at 
https://docs.sqlalchemy.org/en/14/orm/extensions/associationproxy.html
but I don't understand it: It keeps creating new keyword instances rather
re-using existing ones, thus defeating the many-to-many idea. Here's what I've
come up so far, but it predictably fails because I don't want it to create new
Items on its own:

from sqlalchemy import create_engine, Column, Integer,\
String, ForeignKey
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.orm import relationship, sessionmaker, backref
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class Basket(Base):
__tablename__ = 'basket'
id= Column(Integer, primary_key=True)
contents = association_proxy('basket_contents', 'id')

class Link(Base):
__tablename__ = 'link'
item_id   = Column(ForeignKey('item.id'), primary_key=True)
basket_id = Column(ForeignKey('basket.id'), primary_key=True)
quantity  = Column(Integer)
basket = relationship(Basket, backref=backref('basket_contents',
collection_class=attribute_mapped_collection('quantity')))
item = relationship('Item')
name = association_proxy('item', 'name')

def __init__(self, name, quantity):
# this doesn't work b/c it calls Item.__init__() rather than
# looking for an existing Item
self.name = name
self.quantity = quantity

class Item(Base):
__tablename__ = 'item'
id= Column(Integer, primary_key=True)
name  = Column(String(10), unique=True)
weight= Column(Integer)
color = String(10)

engine = create_engine('sqlite://')
Base.metadata.create_all(engine)
Session = sessionmaker(engine)

db = Session()

egg = Item(name='egg', weight=50, color='white')

b = Basket()

# fails because in Link.__init__(), SQLAlchemy wants to create a new Item
# rather than using the existing one.
b.contents['egg'] = 6

db.add(b)

db.commit()

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A 35mm film camera represented in Python object

2021-03-18 Thread Lee Congdon
Note also 36 exposure film.

 -- Film -
Speed:  100 ISO
Rewound into cartridge: False
Exposed frames: 0 (of 24)
Ruined: False

On Sun, Mar 7, 2021 at 5:20 AM D.M. Procida <
[email protected]> wrote:

> Hi everyone, I've created  -
> a representation of a Canonet G-III QL17 in Python.
>
> There's also documentation: .
>
> It's a pure Python model of the physical sub-systems of a camera and
> their interactions. So far it's at a fairly high level - I haven't yet
> got down to the level of individual springs and levers yet.
>
> I spend quite a bit of my time repairing old cameras. To me they feel
> like computer programs encoded into physical objects, and figuring out
> how a mechanism works feels like working out how code works (but more
> fun).
>
> The Canonet G-III QL17 is one of my favourites. One of my reasons for
> writing this code is to appreciate the intricate mechanical logic
> embodied in the machine.
>
> You can do things like advance the film, release the shutter, meter the
> scene with the built-in light meter (if the camera has a battery of
> course) and even spoil your film if you make the mistake of opening the
> back in daylight.
>
> >>> from camera import Camera
> >>> c = Camera()
>
> >>> c.state()
> == Camera state =
>
> -- Controls -
> Selected speed:1/120
>
> -- Mechanical ---
> Back closed:   True
> Lens cap on:   False
> Film advance mechanism:False
> Frame counter: 0
> Shutter cocked:False
> Shutter timer: 1/128 seconds
> Iris aperture: ƒ/16
> Camera exposure settings:  15.0 EV
>
> -- Metering -
> Light meter reading:4096 cd/m^2
> Exposure target:15.0 EV
> Mode:   Shutter priority
> Battery:1.44 V
> Film speed: 100 ISO
>
> -- Film -
> Speed:  100 ISO
> Rewound into cartridge: False
> Exposed frames: 0 (of 24)
> Ruined: False
>
> -- Environment --
> Scene luminosity:   4096 cd/m^2
>
> >>> c.film_advance_mechanism.advance()
> Cocking shutter
> Cocked
>
> >>> c.shutter.trip()
> Shutter opens
> Shutter closes
> Shutter opened for 1/128 seconds
> Shutter uncocked
>
> You can't do impossible things:
>
> >>> c.shutter_speed = 1/33
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/Users/daniele/Repositories/camera/camera.py", line 29, in
> shutter_speed
> raise self.NonExistentShutterSpeed(f"Possible shutter speeds are
>   {possible_settings}")
> camera.NonExistentShutterSpeed: Possible shutter speeds are 1/4,
>   1/8, 1/15, 1/30, 1/60, 1/120, 1/240, 1/500
>
> But you can also do things that you shouldn't do, like opening the back
> of the camera in daylight with a partially-exposed roll of film inside -
> which will spoil the film::
>
> >>> c.back.open()
> Opening back
> Resetting frame counter to 0
> 'Film is ruined'
>
> I hope this interesting to someone.
>
> Daniele
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
+1-202-507-9867, Twitter @lcongdon
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A 35mm film camera represented in Python object

2021-03-18 Thread D.M. Procida
Lee Congdon  wrote:

> Note also 36 exposure film.

That depends on how many frames the Film object has!

Daniele
-- 
https://mail.python.org/mailman/listinfo/python-list


SSL certificate issue

2021-03-18 Thread Sagar, Neha
Hi,

I am facing SSL certificate issue working with python. Can you help me on this.

Thanks,
Neha

DXC Technology India Private Limited - Unit 13, Block 2, SDF Buildings, MEPZ 
SEZ, Tambaram, Chennai 600 045, Tamil Nadu. Registered in India, CIN: 
U72900TN2015FTC102489.
DXC Technology Company -- This message is transmitted to you by or on behalf of 
DXC Technology Company or one of its affiliates. It is intended exclusively for 
the addressee. The substance of this message, along with any attachments, may 
contain proprietary, confidential or privileged information or information that 
is otherwise legally exempt from disclosure. Any unauthorized review, use, 
disclosure or distribution is prohibited. If you are not the intended recipient 
of this message, you are not authorized to read, print, retain, copy or 
disseminate any part of this message. If you have received this message in 
error, please destroy and delete all copies and notify the sender by return 
e-mail. Regardless of content, this e-mail shall not operate to bind DXC 
Technology Company or any of its affiliates to any order or other contract 
unless pursuant to explicit written agreement or government initiative 
expressly permitting the use of e-mail for such purpose.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SSL certificate issue

2021-03-18 Thread Dieter Maurer
Sagar, Neha wrote at 2021-3-18 10:58 +:
>I am facing SSL certificate issue working with python. Can you help me on this.

Python does not directly operate on SSL certificates.
Usually, certificates for trusted CAs (= "Certificate Authorities")
are stored at a standard place (depending on your operating system)
and used for certificate versification by system libraries
implementing SSL/TLS. Python just interfaces with those libraries.

Browsers typically use the same location for certificate verification.
Thus, a first step is usually to verify whether a browser
shows the same issue regarding a specific certificate.
In this case, you would need to install further certificates.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SSL certificate issue

2021-03-18 Thread Paul Bryan
In order for us to help, we'll need to know the details of your
problem.

On Thu, 2021-03-18 at 10:58 +, Sagar, Neha wrote:
> Hi,
> 
> I am facing SSL certificate issue working with python. Can you help
> me on this.
> 
> Thanks,
> Neha
> 
> DXC Technology India Private Limited - Unit 13, Block 2, SDF
> Buildings, MEPZ SEZ, Tambaram, Chennai 600 045, Tamil Nadu.
> Registered in India, CIN: U72900TN2015FTC102489.
> DXC Technology Company -- This message is transmitted to you by or on
> behalf of DXC Technology Company or one of its affiliates. It is
> intended exclusively for the addressee. The substance of this
> message, along with any attachments, may contain proprietary,
> confidential or privileged information or information that is
> otherwise legally exempt from disclosure. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the
> intended recipient of this message, you are not authorized to read,
> print, retain, copy or disseminate any part of this message. If you
> have received this message in error, please destroy and delete all
> copies and notify the sender by return e-mail. Regardless of content,
> this e-mail shall not operate to bind DXC Technology Company or any
> of its affiliates to any order or other contract unless pursuant to
> explicit written agreement or government initiative expressly
> permitting the use of e-mail for such purpose.

-- 
https://mail.python.org/mailman/listinfo/python-list