#tools-and-devops

1 messages ยท Page 51 of 1

sage perch
#

@gusty willow its gonna be an encryption and decryption thing where you have to put a key in beforehand so you can understand the things being sent to you

gusty willow
#

@sage perch so like a web communication thing? Is this for like email or what?

sage perch
#

Kind of my own thing

#

It's a hobby I've been working on in the corona

gusty willow
#

Honestly, encryption with python is pretty easy and well documented

sage perch
#

Well

#

Oof

#

I guess I spelled smth wrong looking for it

gusty willow
#

Well, I misspoke, common encryption is well documented. If you are using some off the wall or custom encryption, that won't be lol

#

But really, unless you are a government, no reason not to just use common encryption

#

Personally, I like ECC

#

Are you wanting to do shared keys or a pki style?

sage perch
#

I'm gonna try to make smth like the enigma machine

#

But I'll probably give up half way thru and use smth else

#

You put a key in at the beginning and then everything you send is encrypted with that key

#

And someone else has to have the same key to understand it

#

@gusty willow

gusty willow
#

Ok, yeah, symmetrical crypto

#

Lots of ways to do that

sage perch
#

Y a y

#

I'm gonna go look for it

#

and hopefully spell it right this time

gusty willow
sage perch
#

Thanks

dusty maple
#

So I'm currently using Travis CI for a project I'm working on, and I'm using tox to run tests on two different Python versions. I'm thinking of caching the .tox directory in the project directory so they persist between builds. Would there be any disadvantages in that?

neon torrent
#

I'm having a very odd error with my gitlab CI pipeline, where i'm cross compiling python packages. it does not work if i use the shared runner, neither if i use my own gitlab-runner running on ubuntu 2004. the only place where it works for some reason is a gitlab-runner on windows (with docker+wsl2)

these are the different platform uname outputs:
gitlab shared runner (provided by gitlab)
Linux runner-72989761-project-19839097-concurrent-0 4.19.78-coreos #1 SMP Mon Oct 14 22:56:39 -00 2019 x86_64 GNU/Linux
my runner on ubuntu 2004
Linux runner-f4dyxxgj-project-19839097-concurrent-0 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 GNU/Linux
my runner on windows
Linux runner-zylfxwum-project-19839097-concurrent-0 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 GNU/Linux

This is the error i'm getting:

/usr/lib/gcc-cross/arm-linux-gnueabihf/8/../../../../arm-linux-gnueabihf/bin/ld: /tmp/pip-install-uhs3msru/uvloop/build/libuv/.libs/libuv.a: error adding symbols: file format not recognized
mighty venture
#

I have got this sick problem with pycharm professional on Ubuntu, I have installed all the packages and setup 'Project Structure' sources but I can't understand why this is not working:

Opening python shell using venv Terminal in pycharm:

>>> import os
>>> os.getcwd()
'/home/dude/Documents/WebDev-Training/Restful Python Web Services/Chapter 2'
>>> import flask_sqlalchemy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'flask_sqlalchemy'
>>>

Opening python console (solo):

>>> import os
>>> os.getcwd()
'/home/dude/Documents/WebDev-Training/Restful Python Web Services/Chapter 2'
>>> import flask_sqlalchemy
>>>

How there is a difference between them? both of them seem to use python virtual environment that I have setup but only one of them is working, I actually need the python venv shell to work

Any help?

[Solved]

umbral jay
#

I am using windows 10 and pycharm. In my Users/<username> folder, I find many pycharm folders of older IDE versions like .PyCharmCE2019.1, .PyCharmCE2018.3. THey take up GByte of space. Can they be deleted safely?

severe thistle
#

So, I keep conda around as my default Python. Work wants me to set an orchestration thing in motion tomorrow on my local machine (they're still setting up my logins and stuff).
the whole thing is in a Poetry environment - are Poetry and Conda gonna cause trouble alongside each other?

#

should I maybe just install the Poetry env into like a Docker container or something?

tawdry needle
#

You can install poetry inside a conda env

sage perch
#

Bois

#

I need some help

#

I'm trying to make the most complicated thing I can

#

That does absolutely nothing

#

Maybe prints smth

#

If anyone can help with making it more complicated please @ me

ebon sail
#

Sorry for posting this in 2 different channels, not sure which would be better. Me and my friend are trying to make a discord bot which i plan to host on my linux server. Are there any free python ide's that can connect to a server(i guess ssh support) so we could both work on it?

wooden ibex
#

VSCode can but that's now how you cooperate

#

take a few hours to learn Git and Github

ebon sail
#

Ok, thank you. I will look into Git/Github

river sinew
#

@ebon sail Bituckets also good, it has unlimited free repos

naive kettle
#

is there certain config u need to set for elixir in travis.yml file ?

heavy knot
#

does anyone know why my vs code editor doesnt auto save anything? i have the auto save turned on

ebon sail
#

@river sinew Thank you

river sinew
#

does anyone know why my vs code editor doesnt auto save anything? i have the auto save turned on
@heavy knot do u have it set to delay?

heavy knot
#

i figured it out thank you

river sinew
#

you're welcome

gusty willow
#

@ebon sail I would be amiss if I didn't mention Gitlab in the "git" discussion (it has the best built-in CI and unlimited teams/private repos)

ebon sail
#

Awesome, thank yall for all the suggestions

sand thistle
#

so, i created a new user on my digital ocean, ubuntu droplet, I was advised that I would have to go and create a new user on there; for reasons I won't go into detail here, however now I actually need to log in to this new user that I've created

#

how would I accomplish that?

#

is that something that is done during the ssh process?

lone linden
#

You can directly login as the user via ssh

gusty willow
#

@sand thistle ssh <new user>@<droplet ip>

#

also ... i can't remember if DO forces you to use SSH keys or not, but if so, you will have to create one and drop the pub key on the droplet and pull down the priv key

sand thistle
#

I got a permission denied

#

Public key

tawdry needle
#

does digitalocean give you a place to put a "public key" @sand thistle ?

#

or an "SSH key"

sand thistle
#

Yes sir

tawdry needle
#

@sand thistle then you need to generate an "SSH keypair", and upload the public key to DO

sand thistle
#

Gotcha

tawdry needle
#

i forget, do you use windows or linux?

sand thistle
#

Unix

tawdry needle
#

ok good

sand thistle
#

So, I did this already

tawdry needle
#

do you have a ~/.ssh/id_rsa file?

sand thistle
#

But for root

#

Yea

#

I've done this before, I just wasn't sure.

I guess I have to make another keypair

tawdry needle
#

you can use the same keypair. in general you dont want to log in as root

sand thistle
#

Ahh, so then just modify the id-rsa

#

File

tawdry needle
#

if your private key is compromised you are screwed anyway

#

no, do not modify that file

sand thistle
#

Loll

tawdry needle
#

definitely do not modify that file

#

how about this

#

go make a 2nd key

#

there is nothing wrong with having 2 keys

#

you just need to keep track of which key is for which account

sand thistle
#

Hmm ok

#

Is that standard?

#

Just curious

tawdry needle
#

i've seen a variety of recommendations

#

nowadays i just have 1 keypair per machine that i use

#

but my hosting company (hetzner) gives me the ability to log in via a virtual console

#

so i dont need to be able to ssh in as root at all

#

so for example if i have 3 computers, A B and C. i make 1 private key on each computer

#

then i can use those public keys in all the places i need to access

#

so i have a public key for A, B, and C on github.com and on my servers

#

note that i am not a security expert

hexed arch
#

Hey everyone

#

Is there anyway to install python 3.8 on shared hosting

#

and setup a virtualenv

tawdry needle
#

@hexed arch you can use pyenv, which installs python in your home dir

#

you just need to add the pyenv bin directory to your PATH

hexed arch
#

I've tried I couldn't seem to get it to work

tawdry needle
#

what went wrong?

hexed arch
#

Let me try it again

#

Yea this is the one I tried

tawdry needle
#

and what was the problem?

hexed arch
#

Can't remember it was a couple hours ago after that I had such a bad time trying to install conda

#

So I run curl https://pyenv.run | bash

#

right

tawdry needle
#

another option is brew (aka "linuxbrew"), which is a general-purpose package manager that also installs itself to your home directory https://brew.sh/

Homebrew

The Missing Package Manager for macOS (or Linux).

#

if you install conda, i recommend miniconda3

#

do not use the full anaconda, it installs a bunch of extra junk

hexed arch
#

Yup thats exactly what I was using

#

miniconda

tawdry needle
#

miniconda3, homebrew, and pyenv should all do what you need

hexed arch
#

Ok so install homebrew to install pyenv

tawdry needle
#

if you can show the error you got, people here can help more

#

no

#

pick one

hexed arch
#

ohhh

#

ok ok

tawdry needle
#

you can install pyenv using homebrew

#

but i don't recommend it unless you already know what you're doing

#

it's better to just pick one of these tools for now

#

usually you can just rm -rf if the installation fails

hexed arch
#

Yea I suck at linux so I probably don't want to touch that

#

let me try pyenv again

#

Just to clarify i run

#

curl https://pyenv.run | bash

#

So I've installed

#

and then used

#

export PATH="/home/u876004025/.pyenv/bin:$PATH"

#

to add it to PATH

#

Ok this is the error I get

#

python-build: TMPDIR=/tmp cannot hold executables (partition possibly mounted with noexec)

#

I guess I have to change the TMPDIR

#

how do I do this? thats what I need to know

tawdry needle
#
mkdir ~/tmp
curl https://pyenv.run | TMPDIR=$HOME/tmp bash
hexed arch
#

So I install again in $HOME/tmp?

tawdry needle
#

no thats just tmpdir

hexed arch
#

ohh ok it sets the tmpdir

tawdry needle
#

yes

#

you should probably set that in your .bashrc

hexed arch
#

ok So i've done that

#

so if I do

#

pyenv install 3.8.0 it should hopefully work

tawdry needle
#

hopefully yes

hexed arch
#

python-build: TMPDIR=/tmp cannot hold executables (partition possibly mounted with noexec)

#

same thing again ๐Ÿ˜ฆ

tawdry needle
#

did you add it to bashrc?

hexed arch
#

nope

tawdry needle
#

you should probably set that in your .bashrc

hexed arch
#

ran right after each other

#

TMPDIR=$HOME/tmp?

tawdry needle
#

yes, in the file ~/.bashrc

hexed arch
#

ok

tawdry needle
#

export TMPDIR=$HOME/tmp

hexed arch
#

problem is i don't have access to .bashrc and even if i do i suck at linux and don't know where it is

tawdry needle
#

you dont have access to it?

hexed arch
#
export PATH=$PATH:~/.local/bin
export TMPDIR=$HOME/tmp
#

and i just run this everytime i login

#

it sets up pip and now the tmp dir

tawdry needle
#

why do you think you don't have access to it?

hexed arch
#

shared hosting

tawdry needle
#

...have you tried creating one?

hexed arch
#

wait

#

i can do that

sand thistle
tawdry needle
#

i mean, i guess it's possible that your shared host would block it from being created

#

but i kind of doubt it

#

i guess you should check to make sure if compiling software is allowed under the terms of service

hexed arch
tawdry needle
#

i'd be kind of horrified if it wasn't allowed

#

it looks like you already have a .bashrc file

hexed arch
#

thats ~ btw

#

oh yea it just made it when i installed

#

pyenv

tawdry needle
#

so what if you just edit the bashrc?

hexed arch
#

yea im doing rn

#

didn't even see it mv

#

mb**

#

didn't work

#

thats ok i have custom method of doing it

#

ok its installing python i think

#

downloading currently

#

configure: error: no acceptable C compiler found in $PATH

#

Now I have to install a C complier

tawdry needle
#

ah

#

that might be a bigger problem

#

i don't think you can easily install GCC yourself

#

conda is a much better option in this case

heavy spire
#

When I was going to enroll in a Data Analytics course, I was told to install Anaconda on my MAC. I did and the latest version of python from Anaconda shows as pthyon 3.7.6. When I type python into terminal, it warns me not to use Python 2. Why does it see Python 2.7 when i have 3.7.6? Do I always have to type in python3 when in terminal?

tawdry needle
#

@heavy spire macs come with both python 2 and python 3

#

do not mess with the system installed pythons

#

make 100% sure you have a conda env activated

heavy spire
#

@tawdry needle how do I ensure I have conda env activated?

tawdry needle
#

@heavy spire if you didn't type conda activate you probably don't have a conda env active ๐Ÿ™‚

hexed arch
#

it will say

tawdry needle
#

it should also adjust your prompt accordingly

hexed arch
#

(envName) at the beginning of the cmd line

heavy spire
#

ah, that worked. When I type in conda activate, it finds python 3.7.6. Thanks!

tawdry needle
#

use conda env list to list the conda environments you have available

#

in general it's recommended not to install things into the base env

#

ideally you create 1 env per project

#

but for simplicity you can create a "sandbox" env or something like that, and activate that env before installing things

#

as a general rule, when working with package managers, you should try to keep the "main" environment clean

heavy spire
#

I haven't even gotten that far. I was just trying to use something other than repl.it to write some python code

#

But that's good to know for later!

hexed arch
#

Salt I had a weird error while installing conda

#

./Miniconda2-latest-Linux-x86_64.sh: line 409: /home/u876004025/miniconda2/preconda.tar.bz2: No such file or directory

#

Any fix?

#

you know what let me try reinstalled conda

#

from the start

#

I go to

#

and download miniconda for python 2.7

#

@tawdry needle Quick questions

#

Should I be getting miniconda3 or miniconda2?

#
Miniconda3 will now be installed into this location:
/home/u876004025/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/u876004025/miniconda3] >>>
PREFIX=/home/u876004025/miniconda3
Unpacking payload ...
Miniconda3-latest-Linux-x86_64.sh: line 409: /home/u876004025/miniconda3/preconda.tar.bz2: No such file or directory
-bash-4.2$
#

I got 3

#

This is the error that i've been trying to fix for a while now

tawdry needle
#

minconda 3

#

always 3

#

i have no idea what that's about. maybe your shared host is blocking certain requests and causing the download to fail

#

you might be stuck tbh

#

what python version is on your shared host?

hexed arch
#

2.7.5

#

I've done a bit a google to no avail

#

Nothing

#

that I found that helped in the first few results

#

@tawdry needle Do you think I could use my linux laptop to install conda into a folder put it onto a usb

#

put it on my main machine

#

and upload it to the server?

#

would that work

hexed arch
#

im downloading redhat linux right now so i dont have any problems with different linux distros

#

im gonna install it on my old laptop

#

install conda

#

and then move it to the server

#

hope this works ๐Ÿ˜‚

#

im going to long ass long route

umbral jay
#

Today is first time I opened a ipynb file. I noticed I can open this file using jupyterlab and jupyter notebook. I'm confused here.
Since lab is newer, is it better to use jupyterlab instead of notebook?

sleek grove
#

Both are fine, lab is newer but if you don't need it's features notebook is fine too.

umbral jay
#

Both are fine, lab is newer but if you don't need it's features notebook is fine too.
@sleek grove is lab more unstable since it's newer?

sleek grove
#

In my experience, it depends. Sometimes labs is more unstable but it does have a lot of nice features. I tend to use notebooks but its also what I'm more used to

umbral jay
#

some ipynb files are huge. Is there a way to set bookmark on an ipynb file?

#

what are pros and cons of jupyterlab vs jupternotebook?

sleek grove
#

labs = more features, potential instability, notebooks = stability, fewer features

marsh rover
#

what does a directory with a yellow highlight mean in PyCharm? (in the project panel)

true vapor
#

.vscode is orange because it's excluded. I'm not 100% sure what the yellow highlight means, but I think it might mean gitignored or something.

If you look in settings, and project structure - you can see what the different file icon colours mean

#

fitle -> settings -> project -> project structure

marsh rover
#

thank you

heavy knot
#

Is there any way to allow interoperability between a Conda env and pip?

hexed arch
#

@tawdry needle Thanks so much for your help yesterday

#

I got conda working ๐Ÿ™‚

#

Heres how

#
  1. Install centos on my laptop
#
  1. waste 40 mins trying to figure out how to make gnome work
#
  1. install conda and put it on a usb
#
  1. upload it via filezilla on my main machine
#
  1. turns out conda files have some hardcoded paths depending on where you install
#
  1. on my linux machine in the home folder make a folder called u876004025 (hosting username) and then install conda again
#
  1. upload it to the server again
#
  1. add it to path
#

and now it works

solid ivy
#

but why tho

#

what does conda provide that a virtualenv doesn't?

hexed arch
#

Heres some context

#

I'm trying to run django but my hosting has python 2.7.5

#

So I need to use conda to install python 3.8

tawny temple
#

Conda is not only a virtual environment tool, it's a package manager too. So it supports packages beyond Python ones. In fact, you can even install Python itself via conda.

hexed arch
#

Yup

solid ivy
#

Fair enough. I just scrolled back and saw your issue. That's nuts

hexed arch
#

Yea ๐Ÿ˜‚

solid ivy
#

I wonder would pyinstaller help here...

tawny temple
#

That's used to install python packages, not for Python itself.

solid ivy
#

No, it's used to create a single executable that contains a python interpreter, the application, and dependencies

tawny temple
#

Yes, that is what I mean

#

Are you proposing to use it to create a dummy package just so you can obtain an interpreter?

hexed arch
#

Conda will be better in the long run because I can use it on the whole server

#

Is pyinstaller like a env?

solid ivy
#

Yeah that's fair. I reread the original problem and using conda is definitely better. I was under the wrong impression that you just wanted to run some script (and pyinstaller would probably be able to do that reasonably well), but having a full interpreter wouldn't really work with pyinstaller

#

pyinstaller is a tool to run some python app as a single executable. it bundles the interpreter and dependencies with the application into an archive. so it essentially contains an env, but it isn't as flexible as having your own installed interpreter like what conda gives you

hexed arch
#

Yea plus I'm not only using this to run django

#

I don't need python 3 for flask

#

I used python 2 and It worked just fine but 3 would be better I guess

solid ivy
#

yeah with py3 you get f-strings \o/

hexed arch
#

Yep

#

Ok so making a new env didn't work for some reason

#

it got stuck with python at 97% everytime

#

so im packing my current env and moving it over

sand thistle
#

how would I actually copy a directory within my digital ocean droplet

#

i have to copy something from root

#

to a user

hexed arch
#

boom got it

#

hopefully this works

hexed arch
#

got it working!

#

its just the django docs first project tutorial thing

mighty venture
#

Hey all

I been working on a flask project and suddenly there was a power-cut and a sudden shutdown, after that when I opened the project, only the index page is rendering, and issues are as follows:

1: everything was working fine before shutdown 
2: I am not getting any exceptions or errors at all, so I am blind here, I don't even know what the problem is 

Also, this is what my terminal shows when I run ./pycharm.sh:
https://pastebin.com/rkz2Hfj2

buoyant canopy
#

Looks like something your text editor uses got corrupted

mighty venture
#

Well I use pycharm for everything I do

#

I also created another flask project and moved all the files there, still it doesn't work

mighty venture
#

I could also use the application without pycharm, I activated venv in a terminal and still couldn't render anything except index page

heavy knot
#

Do you guys use oracle sql database

#

Or does another database work

covert kindle
#

Anyone know how to encrypt a password for a 7z shell function?

In my .bashrc file, I have a function for calling 7z on a folder and encrypting/password protecting the output. The only problem is that the password is in plain-text, so if someone gets into my .bashrc file then it's totally exposed. I'm looking for a way to encrypt it and keep the password safely inside my password manager.

#
function r-nest {
    # Backup PortableApps directory
    # --- Variables ---
    current_date=$(date +"%m_%d")
    input="/A/nest"
    output="/B/Temp/nest_$current_date.exe"
    password="supersecret_plain-text_password!"

    # --- 7-zip ---
        7z a -mhe=on -bsp1 -sfx7z.sfx -xr!plex -p"$password" "$output" "$input"
    7z t "$backup_file" -p"$password"
}
tawdry needle
#

@covert kindle set the permissions to 600 at least

#

or have your bashrc read your password from a file with 600 permissions

#

that way in theory nobody can read the file without "hacking"

#

(or being root)

covert kindle
#

That was my best guess at a solution, but since I use GitBash permissions mean nothing ๐Ÿ‘

Guess I'll just ๐Ÿคž

gusty willow
#

@sand thistle sudo cp <thing> /home/<user>/<thing> && sudo chown <user>:<user> /home/<user>/<thing>

untold zodiac
#

can anyone help me with this

#

i want to get a result like i said above

#

and loop over the code

#

since there is a file which contains many lines of the similar format

near swan
#

im tryng to work with some like 7 year old code
written in python 2
whats the best way to do this in pycharm without fucking up my main python install
on ubuntu btw

dusty maple
#

I suggest looking into installing Python 2 through pyenv

#

It should be relatively painless

near swan
#

hmmm i just dont wanna fuck with paths

#

what if i do

#

sudo apt install python2.7

dusty maple
#

pyenv manages paths for you as well actually

near swan
#

will that mess with paths at all

near swan
#

so

#

im supposed to run make

#

inside this one directory

#

this src directory

#

but when i run it

#

i get this error

#
#! /usr/bin/python

import distutils.sysconfig
from distutils.core import setup, Extension
import numpy as np

numod = Extension('mpolar',
                  sources = ['mpolarmod.c'],
                  extra_objects = ['misc.o', 'multipol.o', 'efield.o'],
                  include_dirs = [np.get_include(),
                                  distutils.sysconfig.get_python_inc()]
                  )

setup (ext_modules = [numod],
       name = 'mpolar',
       version = '1.0',
       description = 'Multipolar expansions',
       author = 'Alejandro Luque',
       author_email = 'aluque@iaa.es')
#

my pycharm seems to be underlining quite a bit of shit but im not sure how to go about debugging this

ivory flame
#

a lot of the components might have changed since python 2, i suggest looking up everything and substituting for the new components/rewriting the code

frank compass
#

For now the problem is not even python related, he gets a command not found when make tries to execute the python file

dusty maple
#

Doesn't seem like the shebang is being taken into account

gusty willow
#

So I recently just completed a job using nomad instead of kubernetes and I highly recommend it.

floral shale
#

@gusty willow I have a "core" Docker stack that is just Consul, Vault and Nomad. Makes a base for a good deal of my work.

signal crest
#

I have a repository where we used to use a development branch which merged with the main branch via a merge commit. We then started committing directly to master and as such the dev branch has been out of sync for a long time.
I'd like to sync these branches up now so future development can be done in the development branch instead. would git checkout development && git rebase master do the trick? Will git understand that master has had a merge/pull come in from develop in the past and that the branches are identical until then?

not sure if this makes any sense, but basically:

master:
some commits -> merge/pull from development commit abc123 -> new commits

development:
cloned from master -> lots of commits -> commit abc123

I want to get the new commits on top of development, add more commits, then rebase those on top of master at some point.

floral shale
#

You should just be able to merge master into develop

signal crest
#

I should be able to use rebase as well right? I much prefer rebase to keep the commit history clean

floral shale
#

You don't want a merge commit?

signal crest
#

not if I can avoid it

#

though if I can't it's not a huge deal

#

does the merge commit serve some kind of purpose, such as telling git which branch it merged from so it's able to do things such as rebase and merging better in the future?

floral shale
#

It's signal to whomever stumbles upon it in the future, should they need it. Who did it, why, any notes. It makes a commit with a message that you can edit or keep as-is.

#

But yeah either method should work I guess.

signal crest
#

hm. you're right. maybe it's better in this case.

floral shale
#

What's your source of truth stored on? Github/lab? Bitbucket?

signal crest
#

github

floral shale
#

My personal preference is to rebase from features and other short lived branches (except for hot fixes) and merge on larger branches so I can easily search for merge commits.

signal crest
#

yeah, that seems to be best practice. the work on this project hasn't been very well organised before, almost all work has been done on master

floral shale
#

Eh, however gets you there. You can always tighten up going forward as needed.

signal crest
#

true true. got it all up to speed now. turns out git merge doesn't even create a merge commit in this case

viscid schooner
#

here anyone configured apache to serve flask app? with cgi?

gusty willow
#

With cgi? I thought that was more of a PHP construct. But yes Apache is ok with flask (just have to build out the wsgi script) @viscid schooner

viscid schooner
#

okay

mental jewel
#

how to install libpng12 package in heroku

tawdry needle
#

python does support CGI i think

#

but yeah most people use wsgi

mental jewel
#

what

#

i dont understand

tawdry needle
#

it was in response to the previous message

#

the name of libpng12 might vary depending on your OS

#

assuming heroku allows you to install anything at all

mental jewel
#

oh ok

ornate lodge
#

Ok. I am having issues activating a Python virtualenv inside a docker container and keeping that container interactive for use both locally and in a Gitlab CI/CD Job. I have tried both (and various form of):

CMD [ "/bin/bash", "-l", "-c", "source /app/venv/bin/activate; exec /bin/bash $@" ]
ENTRYPOINT [ "/bin/bash", "-l", "-c", "source /app/venv/bin/activate; exec /bin/bash $@" ]

This will launch a local interactive run just fun using docker run -it, but fails when being run in Gitlab:

/bin/sh: /bin/sh: cannot execute binary file
ERROR: Job failed: exit code 126

How do I get the python virtualenv activated in such a way that I can maintain an interactive shell in both a local environment and CI/CD environment?

#

I have also trying using an entrypoint script:
entrypoint.sh:

#!/bin/bash
VIRTUAL_ENV=/app/venv
source $VIRTUAL_ENV/bin/activate
/bin/bash "$@"
ENTRYPOINT ["/app/entrypoint.sh"]
gusty willow
#

Why do you need an interactive shell for CICD?

#

In a CICD context, I don't use virtual envs. I have a container per version I need to run it on

#

In a dev env, I understand the shell, but not CICD

ornate lodge
gusty willow
#

First, in CD, I don't use virtalenv, I use the built-in venv

ornate lodge
#

I will look into that

gusty willow
#

Also, I know nothing of Apache spark, but I guess it's a java app?

#

Otherwise, idk why you are using a jdk base image

tawdry needle
#

yes its java

gusty willow
#

Generally, I would sperate the py and Java stuff into separate containers

#

But like I said, never used it

ornate lodge
#

Spark itself is Java, but it lets you run Python on it (as well as Scala, R, and SQL)

gusty willow
#

Also, what is your pipeline trying to do even?

#

There really is no reason to have an interactive shell in a CICD context

#

If you need like a spark instance to run tests and stuff on, I would build out a runner to do that

ornate lodge
#

The CI/CD Job would be something like:

Test Job:
  image: my_image
  stage: test
  script:
  - do x before tests
  - run pytest
  - do y after tests
#

The goal of this docker image is to provide a reproducible execution environment in which tests can be run locally by developers as well as by a CI/CD Job in a CI/CD Pipeline

#

The developer would run the image using docker run and mount their workspace as a docker volume. then they would run the tests locally inside their local image

gusty willow
#

Well, not to knock it, but that is a general misuse of volumes in my opinion

ornate lodge
#

There is a small mountain of dependencies that are required before you can even execute the tests: Java, Python, Spark, and misc python libs and OS packages. It is not trivial to get an execution environment up an running

polar crow
#

any fix?
ERROR: Could not find a version that satisfies the requirement pyinput (from versions: none)
ERROR: No matching distribution found for pyinput

gusty willow
#

@ornate lodge yeah, which is why I suggest a runner rather than image

#

@polar crow sounds like it doesn't exist lol

polar crow
#

wdym

#

what doesnt exist?

gusty willow
#

No such package pyinput

#

Granted, you have given me zero context, so I assume you typed pip install pyinput

#

@ornate lodge I totally get what you are trying to do though, I had a similar, but not as terrible an experience with Jenkins

#

I just need to try it myself in gitlab

polar crow
#

@gusty willow thx

ornate lodge
#

@gusty willow I found a way to get the virtualenv activated by default without resorting to ENTRYPOINT or CMD shenanigans.

RUN echo "source /app/venv/bin/activate" >> /root/.bashrc
CMD bash
nocturne yoke
#

Does anyone know how I would go about fixing a git repo that's linked with a local directory on my PC? I accidentally made a few commits with a file size that exceeds the GitHub limit, but I don't know how to get a list of all the files so I can uncommit/unstage them. By the time it gives me a list, it's too late and stuff messes up.

gusty willow
#

You will have to rewrite git history and it's a pain in the butt lol

nocturne yoke
#

how might I go about that?

gusty willow
#

Unless it's an important repo, I usually just suggest deleting the GitHub repo, starting a new one with the same name, changing the git remote, and try not to make the same mistakes lol

nocturne yoke
#

hmm that was one approach

gusty willow
#

It is possible though, but I'd have to look it up

#

And I'm not in a position to do so

umbral jay
#

I'm confused by this image ranking python IDEs. Is Jupyter Notebook an IDE for python? I thought it's some kind of software to read books that can run python code

hexed arch
#

@umbral jay Just ignore it all and get vs code ๐Ÿ˜‚

#

Its so versatile and has thousands of plugins

#

its also developed by Microsoft

umbral jay
#

Its so versatile and has thousands of plugins
@hexed arch pycharm is still more popular than VS code today.

hexed arch
#

Is python the only language your going to be using?

#

If not, vs code 100%

#

if only python well pycharm as its tailored especially for python

umbral jay
#

ONe can use pycharm for python and VS code for the rest. Hard to beat pycharm for python

#

Surprisingly, free VS code is even more popular than paid Visual Studio. I wonder who's using visual studio and why are they paying when free VS code is so good

hexed arch
#

because visual studio is for c#

#

its made mainly for c# like pycharm is for python

#

its also alot heavier than vs code

#

but for vs you can also use it for c++, f# all microsoft languages basically

gusty willow
#

I use IntelliJ IDEA Ult because I appreciate the tools. There is a lot that the jetbrains tools do that VSCode doesn't or can't yet.

#

Although, the fight is getting less interesting due to LSP

#

Also, I despise Microsoft

#

So that plays in lol

umbral jay
#

Although, the fight is getting less interesting due to LSP
@gusty willow what is LSP?

#

Microsoft has changed. it's friendly to open source today

gusty willow
#

@umbral jay language server protocol

#

And they haven't changed, they are pandering because they lost a ton of developers

#

I'll be the first to say I was wrong if they remain as "friendly" if they win the cloud wars

#

But even vs code, the best parts are still proprietary

zealous atlas
#

how can we see/check deleted text message?

tawny temple
#

Use the on_message_delete event

#

You'll be able to access message.content from the message object it gives you

#

๐Ÿ˜„

#

I guess you mean SMS right?

zealous atlas
#

Yeah!

#

Do not say install this application and follow steps!

tawny temple
#

I don't think the sender is notified when a text message is deleted ๐Ÿค”

zealous atlas
#

I mean, if someone sent any text message then after sometime he/she deleted it.
How can we see/check it?

heavy knot
#

does python have RCS libraries tho?

#

rcs might support it, if the person has a capable phone

tawny temple
#

I understand. I'm saying that I don't think SMS will inherently be able to provide that information.

zealous atlas
#

okay! thanks @tawny temple

umbral jay
#

Anyone tried using Jupyter to replace Excel spreadsheet? possible?

gusty willow
#

@umbral jay very possible, although it looks a bit different obviously

umbral jay
#

@umbral jay very possible, although it looks a bit different obviously
@gusty willow do you think jupyter can be used to replace web dashboards if one can host them online? This way, developers can write simpler python code instead of using complex javascript frontend frameworks like angular or react.

gusty willow
#

@umbral jay I've not heard of them used in this way, but I don't see why not. Although, it sounds like you have significant investment in a dashboard lol. Not sure it's worth throwing that all away

umbral jay
#

no investment in dashboard. lol. I want to avoid complex frontend frameworks and prefer simpler python. Looking for easy way out

gusty willow
#

Have you seen grafana or Kibana?

#

I'll you have to do is build the widgets in those

umbral jay
#

I'll you have to do is build the widgets in those
@gusty willow those are new to me. Reading up on them now. Thanks.

blissful spire
#

does anyone here use VS Code?

#

is this supposed to look like this?

#

can I change some settings to make it look right or am I stuck with this

opaque kettle
#

@blissful spire youโ€™ve installed some sort of plugin

#

Just uninstall /disable it

topaz aspen
#

how do people typically install a particular version of python on Ubuntu?

#

suppose that I wanted 3.7.6, I think I've heard of deadsnakes, is this recommended?

tawny temple
#

Pyenv is another idea

topaz aspen
#

@tawny temple i ended up using pyenv, deadsnakes seemed a bit funky

#

or at least - i didnt' really get it

gusty willow
#

I thought dead snakes was just a repo

#

But yeah, pyenv is what most use, though I tend to just build a particular version from source (with the --alt-install) flag -- which is just the slower way of doing what dead snakes does

#

Or use that versions docker container

wooden ibex
#

docker

elfin rivet
#

Apm commands not working on atom terminal

#

It pop up with bash apm command not found

#

A help would be appreciated

#

Also bash pip not found

topaz aspen
#

@wooden ibex i have never used docker, but am curious as some projects use R as well (so maybe it will help control envs for that per-project too).

I'm wondering what the workflow is like though - I have ~/.virtualenvs at the moment where all envs are stored, would I instead put docker files in that?

#

also the original question was about having a different version of python available to generate venvs from, so maybe that's more what was meant than what i've just said

elder shuttle
#

Does anyone have any recommendations/ guides for deploying/delivering a python project from Jenkins? (for a discord bot) [@ me when you respond pls]

topaz aspen
gusty willow
#

@topaz aspen that's the ones, those are the official ones

topaz aspen
#

cool, thanks

gusty willow
#

@topaz aspen but yes, docker also helps with R environments

topaz aspen
#

I've been writing some shell scripts to setup a server -- install neovim / setup zshell etc... i'm wondering if this is something that docker would typically be used for?

nocturne yoke
#

can someone please help with source control I'm panicking and I think I may have lost 2 weeks of progress
I think github overrode a lot of the files I had locally
or restored them to a past point
and now my progress is all gone

gusty willow
#

What did you do, it doesn't just overwrite things without action

#

Any honestly, you have to try really hard to do that

#

@nocturne yoke

nocturne yoke
#

idk I'm really confused right now and can only really explain on a call

#

but it looks like a lot of my local changes disappeared

#

but only in some directories

#

and it's back to what I have from two weeks ago

#

i want to find out if there are any records of the files anywhere

#

I can see parts of the files in pychace

#

pycache

#

so there's still a trace

gusty willow
#

git log will show everything that happened

nocturne yoke
#

i tried it and it's weird

#

This is the latest entry

#

but I made a lot of changes in the past two days so I don't know what's going on

#

git log isn't really showing me stuff that I did

#

@gusty willow i think i stashed the changes

elfin rivet
#

Any atom ide user here

#

I need help

nocturne yoke
#

would you be able to help me recover stashed changes?

elfin rivet
#

Help๐Ÿฅด ๐Ÿฅด

nocturne yoke
#

I typed git stash apply but I'm not sure where to go from here

#

i see some of the files

gusty willow
#

@elfin rivet I honestly don't know anyone that uses atom

elfin rivet
#

@elfin rivet I honestly don't know anyone that uses atom
@gusty willow setting up atom is hardGWmythsBlobGlare GWmythsBlobGlare

nocturne yoke
#

oh wait i was dumb git stash apply did everything already

#

my files are back and my life is saved

gusty willow
#

@nocturne yoke I figured it would lol

#

@elfin rivet it's not hard, it's just not that great of an ide lol

elfin rivet
#

@elfin rivet it's not hard, it's just not that great of an ide lol
@gusty willow it require packages, and neither package working fine!!

#

I installed linter

#

Flake8

#

Error pop up "error with flake 8 "

gusty willow
#

@elfin rivet just use vscode

elfin rivet
#

@elfin rivet just use vscod4
@gusty willow it had everything installed??

#

Has*

gusty willow
#

@elfin rivet you still have to install plugins, if you want an all inclusive ide, get pycharm

elfin rivet
#

@elfin rivet you still have to install plugins, if you want an all inclusive ide, get pycharm
@gusty willow well pycharm is a python specific ide only right??

gusty willow
#

@elfin rivet kind of, there are plugins for other languages though

elfin rivet
#

@elfin rivet kind of, there are plugins for other languages though
@gusty willow ohkk

gusty willow
#

Unless jetbrains makes a dedicated ide, there are plugins

elfin rivet
#

Bro, pycharm must be having auto completion, error understand

#

Features?

gusty willow
#

Yes, pycharm is the gold standard

#

I'm not going to copy and paste the features, you can read those on your own

elfin rivet
#

never installed it , lemme seeGWmythsBlobGlare

past gull
#

Whats a faster alternative of repl for python ?

#

I feel pycharm and repl are slow if I simply want to see a result of statement in python.

gusty willow
#

@past gull just run it on your terminal

gleaming quartz
#

Any difference between vscode and code?

#

I heard that code is the open-source version of it

errant mirage
#

visual studio has community, pro and enterprise version. community version is free, its an ide for windows and mac. visual studio code is an opensource text editor, that's vscode.

#

vscode and code is the same i guess

tawdry needle
#

@nocturne yoke git reflog can help you too

#

@nocturne yoke if you can back up and write a detailed description of what happened, i might be able to help

nocturne yoke
#

No worries @tawdry needle turns out I had a git stash so all is good. Thanks for the offer though!

tawdry needle
#

๐Ÿ‘

gusty willow
#

@gleaming quartz vscodium is the open source version, vscode and code are usually the same thing depending on OS

#

@gleaming quartz but yes, there is quite a bit of difference between the oss version and the proprietary version (in that it takes a lot of work to get the oss version workable like the proprietary version)

fluid venture
#

i don't know if this is the correct place to ask this thing, but we are hosting a discord bot on a vps, and we have a repo on github. Now everytime we want to update anything on the bot, we have to connect to the vps, and then replace the files. then run the bot again. Is there any way to make this more sort of automated?

wooden ibex
#

Sure

#

create github action upon master/main branch push to login to VPS and stop the bot/git pull/start the bot

#

or cron job that does that nightly depending on downtime acceptability

warm fern
#

poetry vs pipenv

#

Which do we prefer and why?

#

(or a third option?)

#

Reason I ask is because I need to decide how to manage dependencies/environments for a dev team to work on an existing project together.

tawny temple
#

Invest in poetry because it's actively maintained. The state of the pipenv project isn't good. Earlier this year they finally released an update but I'm still not very optimistic.

#

The only complaint I have with poetry is that it doesn't (easily/conveniently) support storing arbitrary scripts to run, though if you're fine with relying on an external for that (I've seen ones in Python like taskipy, but even make will do), then that's not going to be a huge turn off.

#

Another one to keep an eye on is pyflow. It encapsulates more features than tools like poetry and pipenv aim to. However, it's still relatively new. I don't know how stable it is. Last time I checked, macOS support wasn't great.

#

@warm fern

warm fern
#

Thanks @tawny temple . I'll go with poetry.

gusty willow
#

Yeah, poetry is my choice as well

tawdry needle
#

ive heard some complaints about poetry creeping in too

#

got a link for pyflow? @tawny temple

tawny temple
tawdry needle
#

thanks

gusty willow
#

Lol, it's in rust. But that means I can contribute ยฏ_(ใƒ„)_/ยฏ

#

Probably going to look into it though

#

But yeah, there are some gotchas in poetry

#

Last time I checked, the .whl still didn't work

fluid venture
#

@wooden ibex do you think you will be able to guide me a bit?

wooden ibex
#

I'm not familiar with Github actions for SSH

fluid venture
#

oh ok

finite fulcrum
#

Is there a way to send a KeyboardInterrupt through pycharm's run window without the emulate terminal setting enabled?

heavy knot
#

Does anyone reading this endorse and actively use virtualenvwrapper or does anyone else actively think I should not waste my time looking into it?

wooden ibex
#

Iโ€™d only consider it if you critically need it

tawdry needle
#

ive never seen a need for it i just use venv

#

i do like some of the tools they provide but im just not sure how necessary it is nowadays

#

workon is pretty nice

nocturne anchor
#

Hello, I'm new here and with Python. I dont really know where this problem should be put, but I think library argparse is kind of tools in Python. The problem is that i get error " error: the following arguments are required: -i/--image." and I don't know how to fix it and cant handle it myself, would be very appreciated for explain it to me.

rancid schoonerBOT
#

Hey @nocturne anchor!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

nocturne anchor
#

Here is the code: ```python import argparse

import cv2
import numpy as np

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
help="Path to the image")
args = vars(ap.parse_args())

def resize_to_screen(src, maxw=1380, maxh=600, copy=False):

height, width = src.shape[:2]

scl_x = float(width)/maxw
scl_y = float(height)/maxh

scl = int(np.ceil(max(scl_x, scl_y)))

if scl > 1.0:
    inv_scl = 1.0/scl
    img = cv2.resize(src, (0, 0), None, inv_scl, inv_scl, cv2.INTER_AREA)
elif copy:
    img = src.copy()
else:
    img = src

return img

image_name = args["image"]
image = cv2.imread(image_name)
image = resize_to_screen(image)

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (11, 11), 0)

canny = cv2.Canny(blurred, 30, 150)

(_, cnts, _) = cv2.findContours(canny.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

print("Contours in the image, %d" % (len(cnts)))

shape = image.copy()
cv2.drawContours(shape, cnts, -1, (0, 255, 0), 2)
cv2.imshow("Edges", shape)
cv2.imwrite("output.jpg", shape)

cv2.waitKey(0) ```

cobalt cargo
#

With PyCharm, what are the $1, $2 plugins?, is the autocomplete extra???

gusty willow
#

@nocturne anchor so what is the problem exactly? Your argument is set to required, so I would expect that error if you don't provide the argument

#

@cobalt cargo so no, the auto complete isn't extra, but they recently started letting extension devs ask for money

#

I'm just not sure how many folks will pay, or if other, free extensions will just replace them

cobalt cargo
#

@gusty willow so it does have autocomplete/snippets? But more precise is extra?

gusty willow
#

Yes it does autocomplete and has snippets, no it doesn't cost for those features

#

But there are things that aren't free (like database integration - you would need pro for that -- or now some of the third-party extensions)

cobalt cargo
true vapor
#

@cobalt cargo those are community made plugins. You don't need them, and probably don't want them

cobalt cargo
#

@true vapor ok, how about โ€œintelliJIDEAโ€? Or the pro version?

gusty willow
#

Idea is mostly for java, but IDEA ultimate allows for multiple languages

#

Pycharm pro is only useful if you want the web/db integration

cobalt cargo
#

@gusty willow ok, Iโ€™m going to do the monthly plan, $25. So ultimate will work with python?

gusty willow
#

@cobalt cargo yes, but it's not really necessary lol

#

Not sure what you are doing

#

I just use vscode now for the multi language support

cobalt cargo
#

@gusty willow what edge does PyCharm and the plan have over VSC?,

gusty willow
#

Nothing really any more

#

Support plans maybe

#

I would wager that VSCode has more value now, and is free lol

#

Honestly, for python, I find that pycharm quickly becomes a crutch for people

topaz aspen
#

@tawdry needle yeah workon is nice, but i have also ditched virtualenv... this is my workon hack :

workon(){
    proj=$(gfind ~/.virtualenvs -maxdepth 1 -type d | fzf)
    source "${proj}/bin/activate"
}
cobalt cargo
#

@gusty willow so, donโ€™t go with PyCharm yet?

gusty willow
#

@cobalt cargo i wouldn't personally

#

@cobalt cargo the choice is yours though

tawdry needle
#

@topaz aspen i just use zsh-autoenv, all problems solved ๐Ÿ™‚

cobalt cargo
#

@gusty willow ๐Ÿ‘, I have noticed that React is better with local host then Vue is. Python is good with when I start the server. But I think some of the snippets are kinda out of place or donโ€™t show all the time

topaz aspen
#

I have that actually, when you go in a dir and it activates? Though sometimes it doesn't work ๐Ÿค”

cobalt cargo
#

I like how a IDLE has the cli/CDN in place to add

#

@gusty willow is VSC the editor even in data science? Or, when would a IDLE be used? or needed? Thanks!

topaz aspen
#

what do you mean?

#

IDLE isn't ever used afaik

gusty willow
#

@cobalt cargo idle is the built in editor and only used when nothing else is there lol

#

I've never had good luck with it

topaz aspen
#

i think it's written in pure python tho

#

( i might be wrong ๐Ÿ™ƒ )

gusty willow
#

@cobalt cargo but yes, you can do DS notebooks and things like that in VSC, or if you only care about libraries, it supports conda well

cobalt cargo
#

@gusty willow ok, so when would there be a โ€œproblemโ€ that VSC canโ€™t handle? Yea I meant IDE

topaz aspen
#

i never got on with notebooks in vsc , jupyter lab is ok

gusty willow
#

"It is completely written inย Pythonย and the Tkinter GUI toolkit (wrapper functions for Tcl/Tk). IDLE is intended to be a simple IDE and suitable for beginners, especially in an educational environment."

topaz aspen
#

nice

gusty willow
#

@cobalt cargo I've only met one problem that wasn't already solved for me via an extension or LSP, and for that, I wrote the extension lol

#

but there are so many people using vsc now that most of the blind spots are gone

topaz aspen
#

have you tried kite completion in vsc or elsewhere? Idk if it's any use or not

#

i just have coc

gusty willow
#

I just use the MS defaults

#

For python anyway

#

But admittedly, I do less python now than I use to

cobalt cargo
#

I use Kite, itโ€™s good. I also have another AI, but I forgot itโ€™s name

gusty willow
#

I, as DevOps/SRE, spend most of my time with Go, and Rust in my free time. My career is leading me towards data engineering though now, so I'm getting back into the python ecosystem

cobalt cargo
#

@gusty willow so whatโ€™s a good path to gear towards learning/using? I know mainly React and Vue. Then Python is kinda catching on now

gentle sonnet
#

im new to python and testing on windows does anyone know of a premade vm setup for testing python or should i just build one, prefreably unbunto based but bsd is ok too , big ask i know lol

gusty willow
#

I would just use docker

#

More lightweight and disposable

gentle sonnet
#

never tried docker before does it spin up in virtualbox

#

nm ill check it out thx

gusty willow
#

No, just docker lol

#

But as far as paths, that depends on what you want to do

cobalt cargo
#

@gusty willow with the free/community version of PyCharm, can I use Django with it? Where would I run into problems?

gusty willow
#

@cobalt cargo I don't use Django, so I really don't know

cobalt cargo
#

@gusty willow ok. Whatโ€™s a stable path forward with python? Or what to focus on? I can see that Thereโ€™s allot of possibilities.

gusty willow
#

@cobalt cargo what do you want to do? I have a hard time suggesting anything other than generic stuff without any input from you lol

cobalt cargo
#

@gusty willow I like web, but itโ€™s very vague with styling. Then I like JS, but python seems to be better narrowed down at times. I think I might like DS, but Iโ€™m not too sure where to start

gusty willow
#

@cobalt cargo well, if you like web, stick with JS for a while. That can be applied most places. But if you want a more rounded language, python is a great one. So really bone up on the basics and build things. Once you are comfortable, then branch out to more DS things.

#

I really like the course progression at RealPython, so that might be worth looking into

#

!resources

rancid schoonerBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

gusty willow
#

These are good too@cobalt cargo

cobalt cargo
#

@gusty willow thank you!, it helps when what your learning, is put to practice, or even SHOWN , instead of just console concepts. Thatโ€™s where Iโ€™ve ran into problems with JS. Modules are putting things together now.

torpid junco
#

How do I package an application for distribution when the application relies on third party modules?
Simple python scripts that use pure pythonare simple as I can just copy the python file itself.

nocturne anchor
#

@gusty willow ok, understand that, can you explain me where exacly should I provide that argument?

heavy knot
#

im getting a requests.exceptions.ConnectionError
requests.exceptions.ConnectionError: HTTPConnectionPool(host='wasimd', port=80): Max retries exceeded with url: /service2:5001/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f837c5d9510>: Failed to establish a new connection: [Errno -2] Name or service not known'))

#

when using my flask api

#

this is my api routes:

#
from flask import render_template, redirect, url_for
from application import app
import requests import 
from service2src import animalname, animalnoise

@app.route('/')
@app.route('/name', methods=['GET'])
def getname():
    animals = ['Dog','Cat','Tiger','Cow','Owl']
    animal = animals[random.randrange(4)]
    return Response(animal,mimetype='text/plain')```
#

this is my main app api

#

i mean routes

#
from flask import render_template, redirect, url_for
from application import app
import requests

@app.route('/')
@app.route('/home')
def home():
    return render_template('home.html', title='Home')

@app.route('/generate', methods=['GET','POST'])
def generate():
    r = requests.get('http://wasimd/service2:5001/')

    return render_template('generate.html', animalname = r.text)


#

i also tried service2:5001

#

no luck

severe flax
#

I have a python script I want to run and finish everyday, but I don't want it dependent on my computer. How could I implement this? I have a Heroku account

gusty willow
#

@nocturne anchor when you call the script

gusty willow
#

@severe flax what does the script do, that will sway my suggestion lol

#

@heavy knot that URL in the GET request is really strange looking, that is probably your problem

severe flax
#

It runs selenium.webdriver and logins into a website and posts something

#

I"m trying to use Github actions rn, but I don't know how to use it or docker especially installing selenium, plus how to use environment variables for username and psswd. In dockerfile/yaml

gusty willow
#

so anything that requires webdriver eleminates running only on a serverless function, so you are limited to a container or a server and usually in regards to selenium, i suggest an actual hosted server due to the weight of the browsers (although, I've had pretty good luck with the selenium docker container).

severe flax
#

do you think I can create something that uses selenium docker container as a base image

gusty willow
#

yeah, that is typically how it's done

severe flax
#

ok, nice

gusty willow
#

as far as running it on a schedule, i think right away of just triggering the container with a time based lambda or something in AWS

heavy knot
#

How would I do a thing a certain amount of times? Such as if I am writing a file, I don't want to repeat f.write("Text) I want to do it like 10 times

tawny temple
#

Please open a help channel to ask that question. This channel is for tools and devops, as the name says, not for general Python questions

heavy knot
#

Ah sorry about that

floral shale
#

@cobalt cargo I believe it has support built-in for Django. At least the enterprise version does.

cobalt cargo
#

When Iโ€™m working on a Django project..... should I be switching around paths? I was watching a tutorial and the guy switched around paths and urls... like urls.py? And it messed me up

floral shale
#

@cobalt cargo Not sure what you mean by that?

sand thistle
#

I'm having some difficulty onfiguring nginx to serve multiple subdomains

sand thistle
#

i read that you can just put multiple server blocks inside the config file

#

should those be before or after the certbot information

heavy knot
#

What are some reasons to not use Python within a Docker container?

lone linden
#

the maintainence cost of using one, some slight annoyances with debugging containers, mostly things like that ๐Ÿคทโ€โ™‚๏ธ

trail geyser
#

how would I change the background of a slave frame in tkinter

#
    # I am trying to set a frame color but said frame is declaired in a different file and returned to this one
    # but it does appear in the GUI so I assume it is still loaded into memory and editable
    # So I want to do something like "DimmOne.RamDimm.LED0.bg = 'blue'" ```
#

something like that

#

I am trying to make an effects engine for OpenRGB and I need a way to visualize it in the software

gusty willow
#

@sand thistle just put them with your other server block

sand thistle
#

i got it to work

#

just need to get my actual files on there now

#

and umm, mess with the systemd file I think

gusty willow
#

@heavy knot no reason that I know of really but Brunckek had obviously had problems in the past lol. Other than the obvious size of the python containers, I don't really have many complains.

#

@sand thistle I wouldn't mess too much with the service files. What do you think you need to do that can't be done in a config?

sand thistle
#

well currently it's not set to server the correct html files

gusty willow
sand thistle
#

because well, I didn't put any of the html files up

#

only the ones I had for the other subdomain

gusty willow
#

@sand thistle no reason to mess with systemd then, that is config file stuff

trail geyser
#

ah

#

my bad

dim bison
#

im trying to set up vdi with hyper v, but when i try to connect, it just rdps me into the server and not one of the virtual machines, and the server gives this error

Error: NULL```
sand thistle
#

i see

#

@gusty willow

#

well currently it's serving the same html files

#

trying to figure out how to rsync, and exclude the venv folder, and some other files

gusty willow
#

I'm not sure exactly what you are trying to serve, but every python web framework I know of has a WSGI or ASGI interface, so you can just use that instead of trying to serve an entire project root

sand thistle
#

right, but you need to actually have the html files on the server

#

and whatever files you need

thorn kraken
#

anyone here good with docker

#

I build a container and made a bunch of changes, needed to expose another port, made a commit and now when I try to start the container, i'm getting an error that says "docker: Error response from daemon: cannot mount volume over existing file, file exists /var/lib/docker/overlay2/"

#

I had two files mounted, but I can't seem to get it to start now, with or without mounting anything

#

maybe i didnt commit it right

stark hill
#

Hi All, any preferences on a python image processing framework? Will be started a project shortly and would like to get others opinion.

wooden ibex
#

Badsockets, I think you have to stop if volume is required, it's also good reason not use volumes unless required

gusty willow
#

@thorn kraken when you say commit, what do you mean

#

@stark hill images like digital photos or images like disk images?

wooden ibex
#

sounds like docker is messing with his volumes

gusty willow
#

Yeah

thorn kraken
#

@thorn kraken when you say commit, what do you mean
@gusty willow Ended up just redoing all the changes i had made

#

and docker commit currentcontainer currentcontainerv1.2

#

then tried to run currentcontainerv1.2

#

I think i was missing a flag that would have prevented the error

heavy knot
#

The inbuilt terminal in my VSCode installation doesn't take user input via program's input functions anymore. Pressing the return key simply enters a new line and the input is never actually sent to the program. Would appreciate some pointers on what's going on here:

#

It works perfectly fine with the system terminal

shrewd basin
#

Hi everyone
I have found a script made in python which download some videos from a site
but it needs some improvments
here is the script
https://github.com/Jayapraveen/INE-courses-downloader/
GitHub
Jayapraveen/INE-courses-downloader
Python Script to download coures from INE.com website for personal and educational use - Jayapraveen/INE-courses-downloader
For example: the download progress bar does not working
extracting real names from the site, does not working well
you cannot select more courses to download only one at a time
also the script can be improved to download a playlist and not only a course
i am not that good in python and that's why i am posting here

gusty willow
#

@shrewd basin so what do you need help with exactly? This isn't generally a "hey, I have a thing, go make it better" channel.

marble spade
#

I have a cluster on ECS and a service using EC2 type and i have been testing the performance with Apache Bench
Now i have made a SAME cluster with a service but using Fargate type
Everything is the same: Containers, Tasks, Services, Autoscaling...
Now when i was testing
Fargate for some reason has significantly worse performance
The mean response time is about 2x longer than with using EC2
Does someone have an idea why this might be the case?

gusty willow
#

Ec2 backed instances use a more traditional networking back end, fargate is more kubernetes like, and therefore, has further to travel. 2x wouldn't honestly surprised me. @marble spade

marble spade
#

Hmm, what do you mean by further to travel?

#

@gusty willow

gusty willow
#

More hops, more infrastructure to move through

marble spade
#

oh okay, i get it

#

do you maybe know where can I read about this?

#

is this because of the awsvpc network mode to be more specific?

#

or smthn else

gusty willow
#

It's just the way it's architected

#

Aws has a few docs on the fargate architecture you can search for

marble spade
#

Alright, thank you @gusty willow !

gusty willow
#

Not a lot of deep technical things because fargate is a "secret sauce" though

#

At least not that I've found

marble spade
#

Yeah i kind of noticed that haha

gusty willow
#

But admittedly, I'm more GCP these days

marble spade
#

You prefer kubernetes?

gusty willow
#

It's like everything else, kubernetes is great for some things, but generally yes

marble spade
#

for a beginner like me trying out some orchestration methods, kubernetes was 100% easier to start with tbh

#

than ecs

#

the main reason being that the configuration is way more easier, aws cli was very complicated for me

gusty willow
#

Lol I find that hard to believe, but they have been working hard on that

#

Take a look at Hashicorp Nomad also. It's my pre-k8s tool now

#

And sometimes, is the end all be all lol

marble spade
#

i know but I found all that terminology on aws (security groups, vpcs, subnets, services, tasks and whatnot) very confusing lol

#

oh i will check it

#

on kubernetes you can configure some nodeports, deployments, ingress and you have a basic cluster already

gusty willow
#

Yeah, I gets a little crazier at scale, but the same paradigms hold

marble spade
#

hope so haha

#

anyways, thanks for your help!

heavy knot
#

im having an issue

#

with hosting my bot

#

on heroku

#

im getting this error:

#

Push rejected, failed to compile Python app.
! Push failed

#

when i try to deploy

spark sand
#

Show what it says when you try to push something

gusty willow
#

@heavy knot have you tried to run your app locally

heavy knot
#

i fixed everything

#

thanks

sudden lagoon
#

I'm trying to use enums as a key to index into a dictionary but I keep getting a keyerror. Observe...

from enum import Enum

class MyColor(Enum):
    WHITE = 'white'
    RED = 'red'

mydict = {'white': '#ffffff', 'red': '#ff0000'}
print(mydict[MyColor.WHITE])

This will result on a KeyError. However, doing print(mydict['white']) will work.

dusty maple
#

@sudden lagoon The enums themselves aren't actually the strings that you set them to, in this case I believe you'll have to extract it by using the value attribute

sudden lagoon
#

@dusty maple

Is there any better way to do this?

mydict[MyColor.WHITE.value]

I thought I could override the built in function as such...

class MyColor(Enum):
    WHITE = 'white'
    RED = 'red'
    def __str__(self):
        return self.value

...then this would suffice in doing the following...

mydict[MyColor.WHITE]

but it still doesn't work. I was kind of hoping there's an easier way than just mydict[MyColor.WHITE.value]

dusty maple
#

I think you could use enums as dictionary keys

#

!e

from enum import Enum

class Colors(Enum):
  red = 0
  blue = 1
  green = 2

colors = {
  Colors.red: (255, 0, 0),
  Colors.blue: (0, 255, 0),
  Colors.green: (0, 0, 255),
}

print(colors[Colors.red])
rancid schoonerBOT
#

@dusty maple :white_check_mark: Your eval job has completed with return code 0.

(255, 0, 0)
dusty maple
#

But in this case, there's no real advantage over just setting the appropriate tuples for each enum unless you have multiple dictionaries where you need the enums as keys

sudden lagoon
#

ah i see. yea i have a yaml file that is a list of dictionaries...

polybar:
    - grey: '#ffff00'
      red:  '#fff0ff'
      ...and so on
p10k:
    - grey: '#fffc00'
      red:  '#fff0fa'
      ...and so on
...and so on

After I read the yaml file in I was hoping to avoid hard coding my strings and just use an enum class to define them instead. Would make it alittle easier to maintain.

#

in other words the enums in this case are acting as accessors mydict[MyEnum.RED] versus mydict['stringvalue']

#

thanks for the help

ionic nexus
#

hello there can you help me

mystic flint
#

hello, i have an issue with a VPS (heroku) - i have a script that downloads mp3 files via urllib, and the files are there (i can request them via the same script), but whenever the script restarts the files arent there anymore, and if i check via bash the files arent there either - do hosters use some sort of cashed file system? im giga confused

gusty willow
#

@ionic nexus need a whole lot more info lol

#

@mystic flint heroku uses containers, so yes, the filesystem is "cached" (more accurately, it's an ephemeral file system lol). You would need to store your MP3s somewhere else, rather than on disk (think AWS S3 and the like)

mystic flint
#

argh, thats depressing, guess ill have to host it locally or sth... storing new files is core part of my script :/

gusty willow
#

@mystic flint you still can, but you just need different storage lol

mystic flint
#

i have no idea how i would do that, whats the point in storing files on another hoster, in that case i should just host the entire script on AWS...? or what

gusty willow
#

Well, that's your call, but yeah, that's my suggestion

#

I think heroku has a paid plan that includes persistent storage as well

mystic flint
#

damn, was hoping that theres a way to just stop heroku from resetting my container on every restart

#

oh, that might be the case too, right

gusty willow
mystic flint
#

ah yea i see, i think ill just host it on a server of a friend of mine, though i have no idea how i would push with git on another machine except RDPing onto it and pulling manually

gusty willow
#

@mystic flint as far as deploying on your friends machine, you pushing to git can trigger a webhook that can make your friends machine download and run your code, just food for thought :)

#

Although, maybe I'll make a heroku alternative that includes a db, a cache, and persistent storage in the service APIs

cobalt cargo
#

Has anyone created a Automator quick action to enter โ€œpython manage.py runserverโ€

gusty willow
#

@cobalt cargo I don't know what "Automator" is

cobalt cargo
#

@gusty willow its on Mac

gusty willow
#

sounds like it's just a script runner, why not just make a terminal alias that points to a script that just does that ... no third-party tools needed

#

personally though, as far as script runners on a mac goes, I like bitbar

cobalt cargo
#

@gusty willow Iโ€™ve entered a AppleScript to execute, but it dosnt do anything. To even have a shortcut to just paste in the terminal, that would be fine

gray condor
#

Is anybody aware of a library that can parse various markup languages like Markdown/reStructuredText/AsciiDoc ? I'm only interested in parsing, not generating output.

tawdry needle
#

@cobalt cargo create an alias in your bashrc file

#
echo "alias django-run='python manage.py runserver'" >> ~/.bashrc

@cobalt cargo

#

@gray condor pandoc

#

although i dont think asciidoc is supported (yet)

gray condor
#

@tawdry needle interesting idea, I guess the idea would be that I just parse one format and let pandoc convert to that.

tawdry needle
#

im not sure what your goal is. but pandoc keeps an internal syntax-agnostic representation of the document

#

im not sure how easily accessible it is from python though

#

or if theres some way to dump that representation to json or a similar format

gray condor
#

@tawdry needle such a dump would be ideal, esp. if it preserves line numbers of the input files

tawdry needle
#

ahh it only has an asciidoc writer, not reader

#

i remember now, theres an issue for asciidoc reader support on github

#

apparently you can write custom output formatters with lua

gray condor
#

pandoc --from markdown --to json

#

I think this is just what the doctor ordered, thanks a bunch @tawdry needle ๐Ÿค—

tawdry needle
#

oh yeah, nice!

gray condor
#

personally I only care about Markdown, I just didn't want to lock in that decision for people who have other preferences.

#

by the looks of it, AsciiDoc support is only a matter of time

tawdry needle
#

yeah

#

i quite like asciidoc, lack of pandoc support is one of the reasons i havent switched

marble spade
#

Am i able to use only 4 IP adresses on GKE per location?

#

This is from resource quotas on GKE

#

I was just trying to scale up my cluster

#

add more vms

#

does anyone have an idea how i can increase the number of vms without hitting those limits

#

or am I doing something terribly wrong lol

#

when i try to increase the size of my nodepool it displays an error because of resource quotas

#

oh

#

i remember something

#

i actually use nodeports instead of clusterip

#

so every node gets an external IP

#

should switching to clusterip solve this problem? hmm..

gusty willow
#

should switching to clusterip solve this problem? hmm..
@marble spade yes, in production clusters, nodeport isn't used

marble spade
#

@gusty willow yeah i know, but i dont actually need going to production right now, for now i am just testing some autoscaling

#

Its a bit of a hassle that i need to contact google everytime i want to increase my resource quotas...

#

I dont even know what specific quotas should i increase

gusty willow
#

Autoscaling with node ports doesn't work well lol

marble spade
#

why?

gusty willow
#

They are very hard to load balance

marble spade
#

hmm i dont know, ill probably try cluster ip sometime in the future too

#

the reason i used nodeports is because the google just creates a load balancer for you and just follows your ingress rules

#

but that was just a temporary solution of course

#

i didnt want to create my own nginx ingress controller right away

#

google load balancer cannot be used directly with cluster ip, because it cannot reach them since it is external (from my understanding)

gusty willow
#

Yup, but an ingress is the correct way to do it

marble spade
#

you mean ingress like pure rules or the ingress controller?

gusty willow
#

Both lol

#

Google really, really wants you to use istio as well

marble spade
#

oh i heard about istio, never really understood what it does ๐Ÿ˜ฉ

#

some kind of service discovery

gusty willow
#

It's a service mesh first and foremost, but integrates envoy nicely for ingress

#

And it's the preferred Google method for getting traffic into a cluster

marble spade
#

gotta read some more about that stuff

gusty willow
#

Yeah, istio is damn near it's own thing now

#

Almost as complex as the cluster itself lol

#

But it's super powerful

marble spade
#

cool, thanks for info ๐Ÿ™‚

rough marlin
#

Should using the --user as an option to pip install in a way that makes it not show up in the local venv?

#

pytest somehow shows up as in the venv, but I can't use it or the package I'm working on

#

I'm on Windows

#

and not used to it at all

rough marlin
#

so

#

pip list shows that yes, i have pytest installed in the venv

#

but the pycharm package list does not show it

#

or anything else that i should have installed

sand thistle
#

i have a bit of a problem

#

I can't find my wsgi file

#

i did locate, and it gave me a bunch of locations where a wsgi.py file exists

#

they seem to be in site packages folders, or dist-packages folders,

#

but the tutorial I was following wouldn't had me install it in one of thise, it seems to have replicated it to multiple directories

#

I need to modify the wsgi.py file, because I am attempting to serve another .py file

#

I mean it clearly exists since I'm able to serve my app

sand thistle
#

i am in way over my head, and I am freaking the fuck out

gentle apex
#

how does one decrypt a gpg file and read the contents into a variable instead of stdouting the contents

#

i really dont want to write the contents to a file then read that file and delete it...................ugh

tawdry needle
#

In python or in the shell? @gentle apex

gentle apex
#

shell @tawdry needle

#

r u supposed to like pipe the output or sth

#

rn im kinda tempted to ditch shell and just use python ugh

wooden ibex
#

Why not write to file then read it?

#

benefit to writing to file is make sure it's properly sent written

tawdry needle
#

@gentle apex you want to save the output of a command to a shell parameter?

#

use the read command

#
some-command | read -r -d '' command_result
echo "${command_result}"
#

oh thats for zsh

#

im not sure how to do it in bash, 1 sec

#

blah bash executes pipes in a subshell

#

so in bash you have to do this

read -r -d '' command_result < <(some-command)
echo "${command_result}"
#

you can also use process substitution but that's my least-favorite option

command_result="$(some-command)"
echo "${command_result}"
gentle apex
#

ya im using bash

#

just want to read the contents of a gpg file after i decrypt it thats all

#

cuz normally it stdouts the contents if u decrypt it

#

@tawdry needle

tawdry needle
#

ok, so does that help?

#

i gave you 3 options + a fourth option if youre not using bash

sand thistle
#

could someone please explain this portion to me

#
Next, letโ€™s create a file that will serve as the entry point for our application. This will tell our Gunicorn server how to interact with the application.

Letโ€™s call the file wsgi.py:

nano ~/myproject/wsgi.py
In this file, letโ€™s import the Flask instance from our application and then run it:

~/myproject/wsgi.py
from myproject import app

if __name__ == "__main__":
    app.run()
Save and close the file when you are finished.```
#

from this tut

tawdry needle
#

@sand thistle what part is confusing?

#

basically, you don't run your app. gunicorn runs your app for you. so gunicorn needs to know how to start your app. it uses the wsgi.py file to start your app.

tawdry needle
#

does mypy -p not work on editable installed packages? i did pip install -e lib/my-thing which installs the my_thing package, and then did mypy -p my_thing. but got the error "Can't find package my_thing", even though it can be imported. mypy -p doesn't even work on stdlib packages, so i'm pretty confused.

heavy knot
#

anyone here know if there exists a discord image in dockerhub that you can expose to a port? thanks!

tawny temple
#

What is a "discord image"

#

Do you mean an image with a discord bot on it?

sand thistle
#

man

#

I am in over my head

#

burnt out

#

depressed

#

gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.

#

plz help

gentle apex
#

so i was able to get it to work @tawdry needle

sand thistle
#

congrats!

#

good job ๐Ÿ™‚

sand thistle
#

I looked through the gunicorn docs

#

I can't seem to find a command that would allow me to check if a script is bound to gunicorn

lethal belfry
#

Hi guys! Does anyone here have experience with xlswriter?

#

Writing obtained data to excel file

gusty willow
#

@lethal belfry I normally just use csv because it's a pretty universal spreadsheet format. Not sure what benefits (other than maybe some formatting things) you would get from an XLS library

#

@sand thistle are you talking about just seeing if gunicorn is running something?

sand thistle
#

yes

#

well I mean I've done systemctl status systemdfilenamegoeshere

gusty willow
#

that would work ๐Ÿ˜„

sand thistle
#

and I'm getting an error, so I'm trying to see if I actually bound anything

#

apparently the wsgi module is missing

gusty willow
#

remind me again what framework?

sand thistle
#

flask

#

nginx

#

digital ocean droplet

#

gunicorn

#

im following this tutorial, and I've been working on this project, but I think I actually skipped the wsgi creation process

#

but my server is able to serve the app if I just do the ip and the port

#

though it is not able to serve it through the domain name, I get a bad gateway 502

gusty willow
#

TBH, the DO docs are among the best i've read, so yeah, you would have had to of skipped something lol

sand thistle
#

but would it still be able to serve it via the ip and port, without the wsgi?

wooden ibex
#

Also reason docker is cool #201

gusty willow
#

lolol

#

also, Morning @wooden ibex

sand thistle
#

but would it still be able to serve it via the ip and port, without the wsgi?
I've never deployed anything

wooden ibex
#

Morning

gusty willow
#

so re: 502 ... is your NGINX configured to listen to that domain name?

#

nginx will return that if it doesn't know how to do something

sand thistle
#

so that i think is a separate problem

#

but ill check

#

it should be ok

#

because gunicorn is telling me the worker couldnt start

#

and that the wsgi module is missing

#

I have 2 server blocks in the nginx config

gusty willow
#

yeah ... you need to follow the instructions and build out your wsgi.py to run your app ๐Ÿ˜„

lethal belfry
#

@gusty willow Sorry for not replying but someone actually started helping me in the Help-Nitrogen channel

lethal belfry
#

and at the same time I was trying to fix the issue

#

Came to the point where I'm pretty sure what the problem is. However, I'm not exactly sure how to fix it ๐Ÿ˜„

sand thistle
#

@gusty willow do you know if I have two apps on this server, with each their own directories

#

do I need to rename wsgi.py to something else? since it will be the same filename? how does that work

gusty willow
#

nah, just launch gunicorn in a way that you are pointing to the individal files ... but really, you are getting into "it would be nice if these were running in containers" territory

sand thistle
#

gotcha

#

if I have multiple apps do they need to listen to different ports?

#

like

#

ip:5000

#

and

#

ip:5001

#

?

gusty willow
#

yes

sand thistle
#

hmmm

#

well 5001 didn't work

#

site took too long to load

#

weird

#

oh mayb firewall

rancid schoonerBOT
sand thistle
#

this channel is for devops

round kettle
#

sry id dont know which channel is appropriate for this

gusty willow
round kettle
#

ok thx

gusty willow
#

oy, converting a 1TB SDD from XFS to BTRFS is a long process -_-

#

10:21:41 fsmove: progress: 70.0% done, 28.8 gigabytes still to move, estimated 15 minutes left my fingers are crossed that it is actually 15 minutes lol

#

but it's been 15 minutes for a while now lol

sand thistle
#

hey

#

well

#

I'm having issues with the firewall now

#

I added both rules, and now it's blocking both ports for some reason

#

I deleted the rules

#

and then just made one for 5000

#

restarted nginx

#

and then tried it, and it's still blocking it

#

it said that it refused to connect

#

I hate everything

#

I'm making things worse

gusty willow
#

lolol

#

just give me the keys to you server and i'll fix it for you ๐Ÿ˜†

sand thistle
#

uhh

#

no