Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Python3 Migration

Hasan Öztürk edited this page Jun 21, 2021 · 4 revisions

Setup voms proxy (This will be done once)

  1. Get your grid certificate: https://ca.cern.ch/ca/

  2. Create *pem files for public-key authentication.

On your local computer (Requires openssl)

cd ~ # this moves to your home area 
openssl pkcs12 -in myCert.p12 -out myPublicCert.pem -clcerts -nokeys # this creates: myPublicCert.pem 
openssl pkcs12 -in myCert.p12 -out myPrivKey.pem -nocerts #this creates : myPrivKey.pem
  1. Go to lxplus

  2. Move *pem files to the appropriate directory

On lxplus:

mkdir .globus [this is the standard place for voms certificates]

On your local machine:

cd ~
scp ~/myPrivKey.pem lxplus.cern.ch:.globus/userkey.pem
scp ~/myPublicCert.pem lxplus.cern.ch:.globus/usercert.pem

On lxplus:

cd .globus
chmod 400 userkey.pem   # owner read only
chmod 600 usercert.pem   # owner R&W

It's enough to do procedure above, once.

Create your proxy

The following commands should be run in each time you log in to lxplus for running something which contacts CMS services

voms-proxy-init -voms cms 
Contacting voms.cern.ch:15002 [/DC=ch/DC=cern/OU=computers/CN=voms.cern.ch] "cms"...
Remote VOMS server contacted succesfully.
Created proxy in /tmp/x509up_uXXXX.
Your proxy is valid until Fri May 24 21:53:28 CEST 2019
export X509_USER_PROXY=/tmp/x509up_uXXXX # (Do not forget to change XXX part)

Python3 testing procedure:

  1. Create a python3 virtual environment (Only once)
  2. Fork the repository (Only once)
  3. Clone the forked repository (Only once)
  4. Go to python3-migration branch
git checkout python3-migration
  1. Branch off to your feature branch from here:
git checkout -b your-branch
  1. Do your awesome changes
  2. Test your changes
pip install -e . # (Install the current project in editable mode, so that your imports work properly)
python path/to/your/test

Example:

$ python test/python/Services_t/ReqMgr_t/ReqMgrReader_t.py 
/afs/cern.ch/user/h/haozturk/WmAgentScripts/src/python/Utils/ConfigurationHandler.py:17: ResourceWarning: unclosed file <_io.TextIOWrapper name='serviceConfiguration.json' mode='r' encoding='UTF-8'>
  self.configs = json.loads(open(self.configFile).read())
/afs/cern.ch/user/h/haozturk/WmAgentScripts/src/python/Utils/Authenticate.py:20: DeprecationWarning: key_file, cert_file and check_hostname are deprecated, use a custom context instead.
  conn = http.client.HTTPSConnection(url, cert_file = os.getenv('X509_USER_PROXY'), key_file = os.getenv('X509_USER_PROXY'))
/afs/cern.ch/user/h/haozturk/WmAgentScripts/src/python/Services/ReqMgr/ReqMgrReader.py:42: ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('188.184.73.148', 41632), raddr=('188.184.75.95', 443)>
  param={"campaign": campaign, "detail": str(details)})
.
----------------------------------------------------------------------
Ran 1 test in 0.310s

OK
Clone this wiki locally