#tools-and-devops
1 messages Β· Page 64 of 1
i don't see anything that couldn't be put into the class and keep the simplistic import use though
any particular (technical) reason to take the less beautiful route?
Callable imported thing is confusing and weird to me
so is importing things via a function instead of import π
Meh
Modules are objects
It's ok to return them, cf importlib
It's not that weird but maybe something would break if import doesn't return a module... good q for #internals-and-peps
actually, i stumbled over a strange thing that reminds me of this, the only actual issue i had with use() is with dataclasses
it seems dataclasses also manipulate sys.path and does weird tricks on import, which kind of crosses streams with use()
but i never had a problem with use itself not being a module so far
i'll reconsider if someone shows me an example of a lib that operates on modules that couldn't work with use
I imagine there could be other issues, i just don't see a reason for it
All to save the from?
if there was other stuff in the module the user might want, it would make sense to require the from, but as i see it, that's the most succinct form, so i prefer that
Ah yes, thought so, thanks!
Does GitHub really not have a way to view markdown/rst files without rendering them, or am I missing something? π€
Context: I'd like to refer to a line of a rst file in an issue.
You can click the "Raw" button on the file
Hmm, but then you get a text file, and you can't get a permanent link to a specific line.
You can click "Blame" I think, but that has some extra stuff
Ah right. Thanks!
While not lines, if it has headings etc. you can go to those
i was just wondering if it might be useful to add p2p capability to pip? if i add an auto-install feature to use() it might be feasible to add a p2p layer?
or is there already p2p planned for pip itself maybe?
i'm just thinking that maybe with IoT this could be useful.. like if you had a swarm of drones, you could tell one to use a package, which pulls it from pypi, then the other drones could install that package without burdening pypi
Nope
lol
what nope?
i am surpised with hearing how many companies store their repositories on github ... and was wondering why do they do that . Why put their trust into github
i saw theres Git .. which i saw explained as Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows And that makes a lot of sense to integrate that into your company .. rather than creating a system to do that for your company
not that different from using cloud hosting instead of on-site
i havent uploaded anything that is commercial to github, even in a private repository , becuase i see its one more company that can see all of my source code
so thats why its wild to me that larger companies with a lot more expensive software are doing it
I see that
i have uploaded to github .. stuff that consider to be opensource
so it's mostly a matter of companies employing the services of another company
and Git sounds incredible ... you can upload all your source-code where all the engineers are able to reach it , AND it can be integrated with Git for seamless updating , i see trust is kind of out of the equation
i see trust is kind of out of the equation
how so?
Well becuase the gains are so high .
I really doubt private repos are readily available to employees of github or that a company as large as them would risk doing something with them
to having it integrated . And they are a huge company , and of course are legally responsible for protecting the data they store . but i see that is overlooked.
Hosting git or other vcs is not that uncommon, but I doubt there's much more risk having it on github compared to hosting it yourself and exposing it to the internet
i currently have an auction bot on github. It provides valuable information about which items are available at auctions around the US . It's routed with an API . Working on the API and protecting the code .. and just the frontend and integration is opensource
hey can I get some help regarding brython?
im trying to develop a chrome extension using brython. I can get the python console to open in chrome, but I can't get it to run MY script
@runic verge lots of companies pay github for private repositories or even on-prem deployments hosted on internal networks
Version control is really a life-changing tool in programming, distributed version control like git even moreso
Git itself is a very powerful tool with an elegant underlying model... and a confusing command line interface that can be difficult to learn
I appreciate the suggestion to look into DevOps @civic hound , i have heard from others that its important aswell , and i see it is important in a team environment.
i've seen . I have seen already so many times where version control would be life-changing on a project that only i am working on . And then projects with other devs .. it's incredible.
i dont like working on github files, on github (editting the saved code that is on github with the changes of the file on my computer or deleting and uploading the same file when updating) ... I see Git can connect to the repository and make those changes from CMD or from the Git GUI
i am not sure about brython or whether its considered tools /devops . There may be a better channel for the subject . .. I see #βο½how-to-get-help and creating a help channel could get some help (though im not sure of that either , because i see brython may be a specific thing that fewer people are aware of ) . Maybe talking about it in python-general , because there are more users there .
thanks for replying. I am going through the documentation to see if I can find anything. It's unlikely that I'll get help for such a specific thing
hey guys, if anyone knows anything about the http.server module, i would greatly appreciate any help in #help-chestnut
i just saw this phrased like this , in the python-general channel and i thought of the question i heard you had
i see this is a good way of doing it
as the http.server module is also a specialized thing
hope you find what youre looking for @subtle horizon
How would I wait for another github workflow to finish, before continuing with my one?
I know I could do this: ```yml
on:
workflow_run:
workflows: ["Verification"]
branches: ["main"]
paths:
- pyproject.toml
- setup.cfg
- setup.py
which works well, except it could trigger multiple times if say, both `setup.py` and `setup.cfg` were edited, the workflow would run twice, which isn't what i want.
If I however use on push, I don't know how would I wait for the `Verification` workflow to finish, before continuing, and if it fails, this workflow should fail too
Please use reply, or ping me on response
In the same workflow or two different workflow files?
2 different files
https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_run you can use the workflow_run trigger
You can configure your workflows to run when specific activity on GitHub happens, at a scheduled time, or when an event outside of GitHub occurs.
name: PyPi Publish
# Only trigger, when the lint workflow succeeded
on:
workflow_run:
workflows: ["Lint"]
types:
- completed
Example
name of first file should be the exact match of the workflow_run: workflows: ["Lint"] in the second file.
yeah, that's what I did in my example, but since I only want it to trigger on separate files, if they're specified, this triggers 3 times if all 3 files were changed in single commit
Basically are u trying to run the workflow only on those file edits right?
@opaque gorge
oh that was hours ago .
hearing about workflows i am wondering if that's how git projects can be seperated from eachother .. and each project can be worked on seperated . Right now when i do git add <filename> i see it adds it to the same project ... but i am working on something that doesn't belong in the project it is adding the file to . ( we want to have a seperate project .. is it a workflow?)
also looking for a way to link this to github , and separate github projects
nah
https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow (eng)
https://www.atlassian.com/ru/git/tutorials/comparing-workflows/gitflow-workflow (rus, if necessary)
workflows are all about organizing work for one repository and their meanings
- main one about actually collaboration with other developers
- secondary one, to make job easier for devops guys to deploy releases of your project
if you want to have a separate project... it belongs to separate repository.
one repository should have only everything that belongs purely to that project and at maximum it can have... some additions that can be launched only together with the project. (for example my Django projects, have included into them docker-compose/docker scenarios to build Nginx / Redis / Celery containers together with main project,)
I usually answer for myself question, if it belongs to separate repository or not, but asking myself... does it need separate ci/cd, its own pipline runner? if yes -> then create new repository
A deep dive into the Gitflow Workflow. Learn if this Git workflow is right for you and your team with this comprehensive tutorial.
ΠΠΎΠ΄ΡΠΎΠ±Π½ΠΎ ΠΎ ΠΌΠΎΠ΄Π΅Π»ΠΈ Gitflow Workflow. Π£Π·Π½Π°ΠΉΡΠ΅ ΠΈΠ· ΡΡΠΎΠ³ΠΎ ΠΏΠΎΠ΄ΡΠΎΠ±Π½ΠΎΠ³ΠΎ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π°, ΠΏΠΎΠ΄Ρ ΠΎΠ΄ΠΈΡ Π»ΠΈ Π²Π°ΠΌ ΠΈ Π²Π°ΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Π΅ ΡΡΠ° ΠΌΠΎΠ΄Π΅Π»Ρ ΡΠ°Π±ΠΎΡΡ Ρ Git.
btw, recommending to read atlassian guide about git from the beginning "Learn git" up to "Forking workflow" chapter
quite cool one in my opinion
p.s. wink, we are probably from the same country, or at least our origins are.
i figured out what i was looking for , in the meantime . I was looking for pushing to different repositories with minimal reconfiguration.. turned out to be very simple .
git remote add origin2 https://github.com/swordysrepo/usegit2.git
git origin2 branch random
git push -u origin2 random```
jumping between repos checking that out.
this i see is advanced for where i am at . It's what i'm looking for though. I appreciate the mention . Seeing it's what connects Git on someones desktop to a network of "Gits on desktops" and organizes them so they can be committed with less overlapping .
https://github.com/swordysrepo/Windows-10-Toast-Notifications/pull/1
the first github PR request
it was merged! π
Such a simple fix also . (but i looked into it for hours .. to discover where the problem was originating from) @civic hound
changed so that the notifications are always threaded . Seeing they are low processing power with it enabled ... and it prevents difficult-to-solve errors when running multiple files using desktop-...
the profile picture wasn't me . Just a guy i respect . And haven't meant to use this account for the purpose of discussions/joining technical discord when i made the account years ago , so i hadnt changed the profile until now, after a while of using discord for that purpose.
Thanks, I see that it checks the version info from a clone in /tmp
Anyone know how to correctly install all azure SDKs for Python? I'm trying to install azure and I get this error
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output
how are you installing it? i mean whats the command
pip install azure as mentioned https://pypi.org/project/azure/
pip install -U setuptools does this hlp?
Nop, still get the same error
umm, do pip --version
Even if I specify the version like this pip install azure==5.0.0 it doesn't work
20.0.2
try updating it
could you send the full output of when you do pip install azure
Hey @ripe junco!
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:
Ok, I think I've solved it
I've installed version 4.0.0
Starting with v5.0.0, the 'azure' meta-package is deprecated and cannot be installed anymore.
Yeah, I did not pay full attention to the text π
Still, thanks a lot @supple venture
https://pypi.org/project/azure/ you can read the README
There is no reason to grab base azure package, they have packages for all their services including rest api. Which is pretty bad
I'm not sure it's the good section but I don't find anything ANaconda-related
conda has a bug with dependencies. Soemtimes it takes eons before checking on the conflicts. I abort with Ctrl+C and relaunch the command
And it works Idg why. Anybody has this bug?
i have a django powered website that needs to be hosted for a fairly affordable price, ive been given the target of <$30/mo but im not sure if that will happen.
where might i get a decent VPS for this price?
I believe this community hosts their site on Linode
im not sure what that is, is it a VPS provider?
You could also use something such as AWS, Digitial Ocean, etc.
That's one thing it offers, yes
aws seems good, too many options for me to wrap my head around tho lol
im really not a devops person, more frontend tbh. we're a small company so ive just been loaded with everything to do with the website.
what would aws's webhosting service be? or at least the best fit
Create, configure and deploy a Django application to AWS Elastic Beanstalk with the EB CLI.
ah awesome! i'll have a read through. thank you
Np
just to check, what im getting from that is i need an EC2 server instance, and then i use EB to manage moving the the project from my computer to the server as well as linking to a domain, did i get that right?
okay cool, i'll have a play around with this leading up to the end of the project and hopefully get everything sorted. thanks again!
I just stumbled upon https://deepnote.com/home, does anyone use this? Would love some thoughts if you do
isn't this what jupyter does too?
all these not-jupyter notebooks are too focused on "cloud" and "collaboration" and not enough on "being more usable" imo
it's the same feature set rehashed over and over
data science ux generally still sucks
I guess their focus is a little bit more "publishing" slanted and trying to make the ui/ux a little cleaner looking but yeah; I'm a fan of https://observablehq.com/ and I think this is someone trying to do something similar for python? π€·
Any1 here using GitHub SuperLinter? I started using it a while ago and it works - showing me that I have linting errors on PR.
Question is: Is there a way to automatically fix the (easy) lint problems - something like x= 1 to x = 1? I didnt find an option to autoformat the code.
I think black allows that - however I use other languages as well in my project so a tool like "SuperLinter with Autoformatting" would be amazing.
is there a way to use pip inside a script as an API from within a script without calling it as a subprocess?
i can call it as a subprocess, but python -m pip download requests==2.6.0 for instance puts the file in the cwd with a name that isn't 100% predictable
i could glob for that with the name-version as a pattern, but it would be nicer to have a function that would just give me the file name
after downloading it
having asked this, i just discovered https://pypi.org/project/pip-api/
i'll try that
it's unofficial though
pip doesn't guarantee any stable python api (annoyingly)
you could parse the output i guess
import re
import subprocess
proc = subprocess.run(['pip', 'download', name], stdout=subprocess.PIPE)
m = re.search(r'(?m)^Saved (.*)$', proc.stdout)
save_location = m.group(1)
very annoying that you can't configure this
maybe use a temporary directory, and run pip in that directory? using the cwd= option
subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None, capture_output=False, shell=False, cwd=None, timeout=None, check=False, encoding=None, errors=None, ...)```
Run the command described by *args*. Wait for command to complete, then return a [`CompletedProcess`](https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess "subprocess.CompletedProcess") instance.
The arguments shown above are merely the most common ones, described below in [Frequently Used Arguments](https://docs.python.org/3/library/subprocess.html#frequently-used-arguments) (hence the use of keyword-only notation in the abbreviated signature). The full function signature is largely the same as that of the [`Popen`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen "subprocess.Popen") constructor - most of the arguments to this function are passed through to that interface. (*timeout*, *input*, *check*, and *capture\_output* are not.)
okay
!d tempfile
Source code: Lib/tempfile.py
This module creates temporary files and directories. It works on all supported platforms. TemporaryFile, NamedTemporaryFile, TemporaryDirectory, and SpooledTemporaryFile are high-level interfaces which provide automatic cleanup and can be used as context managers. mkstemp() and mkdtemp() are lower-level functions which require manual cleanup.
use TemporaryDirectory
yeah, i planned to use that for the "not-in-a-virtual-env" case.. i figured out how to detect whether i'm in a virtual env or not, should i use TemporaryDirectory either way?
it might be a bit awkward (but probably safest) to use it in all cases
it will certainly be slowest to re-install it every time the program is run, though.. on the other hand, i'm planning on incorporating some p2p distribution of packages, which might alleviate this problem somewhat
let's try to make it work for all cases first and have it save and slow before making it fast π
safe*
This is just for controlling where pip download dumps its files right?
Maybe you can integrate with the existing pip cache somehow
Pip already has a download cache
Would be silly imo not to be able to use it for this
Why do you even use pip download? I believe pip install has options to control where exactly the package is installed to
s
@tawdry needle i need to first download the file in order to check its hash before installing anything malicious
having looked at pip's code, i think it might be most reasonable to simply utilize pypi's pretty slick json API
via requests
so far it's no big trouble to get the fitting wheel, the bigger next hurdle is how to install it in a way it can be directly loaded
i fear only packages with a setup.py (whose requirements are already fulfilled or that can be auto-installed themselves) can be auto-installed
which wouldn't be a big issue for me, but others might complain π
with auto-install requiring a proper hash with version-pinning, it might even be a more future-proof way overall
i feel no pressure to match or replace pip in all its features, though. i think it's a great alternative as a command line tool
but thinking of typoes and malicious packages on pypi, insisting on version pinning and hashes is the most straight forward way to get to a really secure supply chain
which, in my opinion, is done best directly in the code doing the import to be 100% clear on what exactly is used
if that only contains the wheels, i could use that, sure
honestly, i feared getting the package from pypi would involve a lot more jumping through hoops, but it was very straight forward after i discovered https://warehouse.readthedocs.io/api-reference/json.html
it's also easy to check the available links for a matching hash, so that's even simpler for the user than what pip hashing mode suggests - it asks the user for a list of possible hashes
installing and importing a package might become as simple as use("yourpackage", version="1.2.0", hash_value="7a7a8b91086deccc54cac8d631e33f6a0e232ce5775c6be3dc44f86c2154019d", auto_install=True)
copy&paste-able anywhere π
does someone mind helping me with a problem that ive facing while working on a python script for the back end?
ModuleNotFoundError: No module named 'sklearn.linear_model.logistic'
this is the error that m getting and Ive already installed sklearn
dm me if someone thinks they can help me out
did you import it
try import sklearn before where you call it
Yes I did
I am in dire need for some help I am a beginner and I have a very important submission tomorrow I've been working on this for 2 weeks and I can't solve this error
@lament compass this is a tools/devops channel and your question is not related to tools/devops at all. I suggest you open a help channel with:
The code you want to execute
The error message
M trying to develop a flask app and having trouble with a python module that's why I ended up posting the quesry here
I think you have to import the specific inner module of sklearn
From sklearn import linear_model then call linear_model.logistic_regression()
what should one do to have a perfectly structured python project on github?
i've looked around at repos, but can't find a certain common way
there's no "perfect" structure
and don't worry about github so much - whatever is good in general is good for github
i generally follow this layout, except i also include a pyproject.toml file https://blog.ionelmc.ro/2014/05/25/python-packaging/
Thoughts on packaging python libraries β Note This is about packaging libraries, not applications. βΈ» All the advice here is implemented in a project template (with full support for C...
same βοΈ
does any 1 here has uploaded python package in pypi
i'm getting this error even tho my token is correct
actually yes .. theres a way to pass in a file .. that has the credentails
i forget whether i found out how to do this without the file ..
It is a common issue
what are you using to upload to pypi? @sacred dragon
I heard twine is a package that is the one that is supposed to work . And heard other packages might throw errors like this . From what i've gathered about uploading to pypi .. it is a fragile process , but once you've got it working it should work consistently.
i'm using twine
consistently
it's my third release
and it shows like this for the first time
Hi this is my post here, I am trying to load and work with DMN files. Can anyone suggest me a Library to use?
do these not work?
I've created dmn xml based file in signavio and then trying to import in python. by pyDMNrules i can't do it. i tried cDMN API it doesn't work
ERROR: Command errored out with exit status 10:
command: 'c:\users\co\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Co\\AppData\\Local\\Temp\\pip-install-l_p5bva2\\pycurl_ca46745b7aa24090bf02fc06186d5660\\setup.py'"'"'; __file__='"'"'C:\\Users\\Co\\AppData\\Local\\Temp\\pip-install-l_p5bva2\\pycurl_ca46745b7aa24090bf02fc06186d5660\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Co\AppData\Local\Temp\pip-pip-egg-info-1q1wejsn'
cwd: C:\Users\Co\AppData\Local\Temp\pip-install-l_p5bva2\pycurl_ca46745b7aa24090bf02fc06186d5660\
Complete output (1 lines):
Please specify --curl-dir=/path/to/built/libcurl
----------------------------------------
ERROR: Command errored out with exit status 10: python setup.py egg_info Check the logs for full command output.
``` When trying to install pycurl.
Anyone? Would be very apprciated.
would be great help if you find around a solution π
can't find anything π
Maybe this is the correct channel..
Hello.
I have been struggling with this issue for a long time now and I can't find answers online.
I'm trying to deploy a Flask app to an Apache server, with fcgi.
The file that runs the app, dispatch.fcgi, is below.
The issue is that when deployed, it can only find the routes that are @idle salmon.route in the same file.
It does not find any of my blueprints or blueprint routes. Nor can I create blueprint routes in this file after creating the app.
The application works on my local. Only difference is that instead of this file I run a run.py which just creates the app without extra config that Apache wants.
How can I get it to find my blueprint routes?
PS: It's a shared host, therefore I don't have root access so the fix I'm looking for should probably be on py side.
#!/usr/bin/env python3.7
import os, sys
sys.path.insert(0, "/www/apache/domains/www.somedomain.com/hinnang/hinnangapp")
from hinnangapp import create_app
os.environ['REQUEST_METHOD'] = "GET"
os.environ['SERVER_NAME'] = "somedomain.com"
os.environ['SERVER_PORT'] = "80"
os.environ['SERVER_PROTOCOL'] = "HTTP/1.1"
DOMAIN = "somedomain.com"
PREFIX = "/www/apache/domains/www.somedomain.com/"
sys.path.insert(0, os.path.join(PREFIX, ".virtualenvs/hinnangapp/lib/python3.7/site-packages/"))
from flup.server.fcgi import WSGIServer
from flask import Flask
app = create_app()
@app.route("/")
def hello(): #<- this works
return "Hello World! <a href=\"test/\">to test</a>"
class ScriptNameStripper(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
environ['SCRIPT_NAME'] = ''
return self.app(environ, start_response)
app = ScriptNameStripper(app)
#@main.route("/home") #<- tried to create a route for a blueprint here, didn't work
#def home():
# return "home"
if __name__ == '__main__':
WSGIServer(app).run()
having a problem where git says everything up-to-date but its not
tried another way and i get GitHub - error: failed to push some refs to 'git@github.com:myrepo.git'
and found on google ... ```In my case git push was trying to push more that just the current branch, therefore, I got this error since the other branches were not in sync.
To fix that you could use: git config --global push.default simple That will make git to only push the current branch.
This will only work on more recent versions of git. i.e.: won't work on 1.7.9.5``` My branches are also not in sync , going to try the git config adjustment git config --global push.default simple and report back
heard it from this link https://stackoverflow.com/questions/10753268/github-error-failed-to-push-some-refs-to-gitgithub-commyrepo-git
I am getting the following error. How do I resolve?:
git add .
git commit -m 't'
git push origin development
To git@github.com:myrepo.git
! [rejected] development -> develo...
it didn't change . hadn't noticed that i was getting this error before though error: src refspec database does not match any
my branches are kind of a mess . Have been switching between them on git not knowing what it actually does . (it says certain files need to be removed before switching . )
and when i run git add (some files) after removing cached with git rm --cached . -r , and then commit the adds with git commit -m "database initial commit" , it says nothing changed . (even though there should be no record of the file , after it has been removed from cache)
(myactivity) [documentation +8 ~0 -0 !] C:\github\api-side-twitch
> git ls-files
.gitignore
README.md
(myactivity) [documentation +8 ~0 -0 !] C:\github\api-side-twitch
> git rm --cached .
fatal: not removing '.' recursively without -r
(myactivity) [documentation +8 ~0 -0 !] C:\github\api-side-twitch
rm '.gitignore'
rm 'README.md'
rm 'database.ini.example'
(myactivity) [documentation +0 ~0 -3 | +11 ~0 -0 !] C:\github\api-side-twitch
> git ls-files
(myactivity) [documentation +0 ~0 -3 | +11 ~0 -0 !] C:\github\api-side-twitch
> git add .gitignore
(myactivity) [documentation +0 ~0 -2 | +10 ~0 -0 !] C:\github\api-side-twitch
> git add README.md
(myactivity) [documentation +0 ~0 -1 | +9 ~0 -0 !] C:\github\api-side-twitch
> git add database.ini.example
(myactivity) [documentation +8 ~0 -0 !] C:\github\api-side-twitch
> git commit -m "initial database commit"
On branch documentation
Untracked files:
code
config.py
connectdb.py
create_api.py
handle_requests_api.py
models.py
recieve_as_api.py
templates/
nothing added to commit but untracked files present
(myactivity) [documentation +8 ~0 -0 !] C:\github\api-side-twitch
> git ls-files
.gitignore
README.md
database.ini.example
(myactivity) [documentation +8 ~0 -0 !] C:\github\api-side-twitch
> git push origin database
error: src refspec database does not match any
error: failed to push some refs to 'git@github.com:swordysrepo/api-side-twitch.git'
this is also a private repo
and i just set up SSH
i think i broke git π
#help-dumpling
edit:
resolved #help-dumpling message
it wasn't SSH , i see it's becuase git was in the documentation branch and trying to push to the database branch (throwing the src refspec error) . creating a local database branch would have worked as git push origin database . but i decided to revert back to just 2 branches , main and staging
Any library I can use to detect languages used in a repository? like cloc but native within python?
You could make a GET request to https://api.github.com/repos/{user}/{repostitory}/languages
I was more thinking of a local directory that might not even be git
Oh, my bad
no problem, its a good thought!
I think I can just manually parse the output of cloc --json by using a JSON parser
If you know how to code in Pycurl/pyurl shoot me a dm right now!
Hi, has anyone done text extraction using pytesseract or worked with image pre-processing?
Hey, can you help me? I just want to make a simple youtube downloader and I get this error every time π
Youtube downloaders are against its ToS, so we won't discuss that here.
hello folks, does someone know is there a way to strip JAVA_OPTIONS from output of java -jar...
IK it's python discord but it's messing up my python tool
Oh, okay :)
Hey @wise tiger!
It looks like you tried to attach file type(s) that we do not allow (.bat). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
where is a channel to learn phyton
Trying to visualize the way I do this project.
I have a piZero with a camera. Was going to do facial recognition.
its Headless to I have to SSH into it.
What is the testing like for this? I just need to make the pi create pictures,
send to a folder and have my desktop running a program to do facial recognition?
or is the piZero supposed to do it all? which its hard to test what it sees over SSH.
If you have enough storage on the device, then you can keep your trained model there and try to recognize faces per-image based on that model.
That being said, modern systems such as Amazon Alexa have such massive always-changing-models, that data is definitely going to the cloud for processing
You can probably go either way
Either way, my recommendation will be getting the simplest solution working first
Then any related problems will be clear, and you'll have something that works that you can maybe redesign or expand on
I also recommend at having a look at publicly available cloud services, such as https://cloud.google.com/vision/docs/detecting-faces
This is a strong route to go, unless your intention is to understand the recognition and training algo's yourself, potentially to get closer to generic machine learning
Thanks, ya i was just trying to understand how it works to build it myself.
It depends on the type of testing and what you are trying to optimize for:
- Create a dataset (ie. pictures from your camera) you can use to test on your desktop?
- Make it available through http so you can visualize it on your browser?
What's the implication of terraform hitting 1.0 on version
Also I'm being sent for RHEL training, anyone know a good discord for that
py charm vs vs code which is better
hey guys
I accidentally overwrote friend's package-lock.json file with my file upload (I added by file-upload a file with the same name)
I didn't know that it will do that, I thought that it will merge somehow (newbie mistake)
is it okay if I just copy the content of my friend's package-lock.json into mine?
Better suited for #editors-ides, it ends up on personal preference both are great editors.
people usually use git for that
restoring file from previous commit
git checkout <path to file>
Hi, I m coding a program and I want it launch with windows, how can i do ?
does anyone know of a good CLI python script i can run which generates prompts for filling in DESCRIPTION, README, puts init into a directory, etc? basically a quick package generator
Sounds like you want cookiecutter
this looks exactly like what i was looking for...THANK YOU. you saved me from spinning my wheels
NOTE: You must install tkinter on Linux to use MouseInfo. Run the following: sudo apt-get install python3-tk python3-dev
that's a weird note
that will depend on your os of course... not all linux distros are the same
debian takes the approach of breaking out parts of the python stdlib into separate installable packages
I use Ubuntu until not
what would such a thing do?
apperently it is a shortcut to create virtual machine with running docker inside
so, a layer of isolation. Instead of running containers directly in your server, to run them in a quickly raised virtual machine
it would be useful for situations when your application is made of many microservices
in order to make isolated sandbox environment to test them without port and other conflicts
$ docker-machine create -d virtualbox testenv
Creating VirtualBox VM...
Creating SSH key...
Starting VirtualBox VM...
Starting VM...
To see how to connect Docker to this machine, run: docker-machine env testenv
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
testenv virtualbox Running tcp://192.168.99.101:2376
To see how to connect Docker to this machine, run: docker-machine env testenv
Time to learn ansible
[git]
I made a commit, but I have new changes again, what's the best way to update with the same commit message?
it's not a good idea to reuse the same commit message in general
you could write a shell script to get the previous one and then make a new commit with that message, but i don't know why would you want to
oh god, it it just a small update to the last one
I had a typo
I want it to be just one commit
I did not push it yet
Git cheat sheet that serves as a quick reference for basic Git commands to help you learn Git. Git branches, remote repositories, undoing changes, and more
not sure where to ask this or if i can ask this in this discord, but can someone help me with docker? im getting really weird errors and i have no clue what could cause the errors
none of my imports are working when i go in the docker with docker-compose exec (containername) sh and try to run a py file
except the requirements.txt installed imports
container is isolated environment, only the modules you installed in Dockerfile are available
im trying import files that are in the same folder on the docker container
ill show you 1 sec
it depends if you are in your own branch, or in public branch
if in public branch... better reverting previous commit. (it will create second commit that handles reverthing previous one) Not exactly fulfilling the goal to keep shorter commit history though. But that's the only best way to cancel commit in public branch
if in your own branch (which you have before it will be merged to some public branch)
just do git reset --soft HEAD~1
it will cancel the last commit while keeping all your changes from it
and commit everything again
these files are in the root of the container, for some reason the Flask directory is still there even tho i removed it from my project
Dockerfile __pycache__ app.py boot dev etc kubemanifests.yaml lib64 mnt proc root sbin srv tmp var
Flask app bin config.py docker-compose.yml home lib media opt requirements.txt run scrapes sys usr
then ill need to go to the directory app
Dockerfile __init__.py __pycache__ config.py database.sqlite forms.py manager.py models.py reddit routes.py static templates
and then i type: python manager.py db --help and its saying the imports arent working, while the imports i use are:
from app import app, db
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
and it cant find the module app
more of a code?
show us at least docker file
version: '3.7'
services:
flask_app:
container_name: 'flask_app'
build: '.'
environment:
- FLASK_APP=app.py
- SQLALCHEMY_DATABASE_URI=sqlite:///database.sqlite
ports:
- "8001:5000"
volumes:
- .:/Flask
depends_on:
- redis
simple_worker:
image: 'python:3.8-alpine'
container_name: 'worker_flask'
build: '.'
volumes:
- flaskapp:/var/lib/flask/data
environment:
- SQLALCHEMY_DATABASE_URI=sqlite:///database.sqlite
depends_on:
- redis
- flask_app
command: rqworker --url redis://redis:6379/0
redis:
container_name: 'redis_flask'
image: 'redis:4-alpine'
ports:
- '6379:6379'
db:
image: mysql:5.7.22
restart: always
environment:
MYSQL_DATABASE: main
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
volumes:
- .dbdata:/var/lib/mysql
ports:
- 33067:3306
volumes:
flaskapp:
FROM python:3.8-slim
# layer caching for faster builds
COPY requirements.txt /
RUN pip install -r /requirements.txt
#COPY app.py /app.py
COPY . /
WORKDIR /
ENV FLASK_ENV=development
CMD flask run --host=0.0.0.0
#CMD gunicorn --workers $WORKERS \
# --threads $THREADS \
# --bind 0.0.0.0:$PORT_APP \
# --log-level DEBUG \
# app:app
from app import app, db
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()
a moment
FROM python:3.8-slim
COPY requirements.txt /
RUN pip install -r /requirements.txt
COPY . /
WORKDIR /
ENV FLASK_ENV=development
CMD flask run --host=0.0.0.0
this should be fixed for sure... for...
FROM python:3.8-slim
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
COPY ./requirements.txt ./
RUN pip install -r requirements.txt
# Create directories app_home and static directories
ENV HOME=/app
ENV APP_HOME=/app/web
RUN mkdir $HOME
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
COPY . .
RUN chmod 777 $APP_HOME
ENV FLASK_ENV=development
CMD flask run --host=0.0.0.0
That would work better.
the thing is / address is filled with system things
it is already full
not the best place to run application
oohh okay thanks! im gonna change it to that
btw when i try to remove the Flask directory its saying there are still things running in there, do you think what could cause that? afaik there cant be anything running in there and it shouldnt even exist since i removed the directory
make .dockerignore file btw
and include into it ignoring everything your .gitignore has
venv especially
okay thanks ill do that
docker-compose up --build
will cause rebuild and run
or actually
docker-compose build
π
im gonna try it!
the last and the most important advice
when you call docker ps
from another terminal, you can see your conainers running right?
yeah
docker exec -it <containerID> <linux command> will run command inside the container
so
docker exec -it <containerID> ls /
or docker exec -it <containerID> ls /app/web
and you will see stuff copied to cintainer
or even...
docker exec -it <containerID> apt install mc
docker exec -it <containerID> mc
and navigate inside the container with Midnight Commander)
nicee im gonna try it out
pip install takes a while to do since it includes all anaconda installs also
this one isnt working its giving this error:
docker exec -it f7bf3a0f7f7b apt install mc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mc is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'mc' has no installation candidate
apt get update
before trying that
im getting this error when trying it:
docker exec -it f7bf3a0f7f7b apt get update
E: Invalid operation get
ops..
apt-get update
or apt update
nice its working!
nice ill also try that
btw
do you know why Flask is still there and i cant remove it?
take down flask_app conainer I guess
docker ps
docker ps -a
thanks it worked!
im still getting that weird error btw that the imports arent working:
root@968472cb319f:~/web/app# python manager.py db --help
Traceback (most recent call last):
File "manager.py", line 1, in <module>
from app import app, db
ModuleNotFoundError: No module named 'app'
its weird since the manager.py is in the app directory
@rapid sparrow why PYTHONUNBUFFERED?
my memory says that docker-compose running application swallows your stdout
PYTHONUNBUFFERED helps to return it back
i haven't had any issues with this, i've been using python and docker compose at work extensively for months
maybe it's an old bug or something
https://stackoverflow.com/questions/51362213/docker-compose-not-printing-stdout-in-python-app
people have issues like that in stack overflow
perhaps at least some docker-compose versions do that
interesting, it could have to do as much with the OS inside the container as with docker-compose
it looks more like they just managed to write a buggy application and it happens to be in docker-compose
why this question was not closed as unclear i have no idea
no minimal example, screenshot of some random output, not even a snippet of a dockerfile
By default, Python buffers output to sys.stdout.
PYTHONUNBUFFERED: 1 This will cause all output to stdout to be flushed immediately.
perhaps there is a differnece between sys.stdout and stdout
and docker-compose shows only stdout
does someone know a fix for this? might be because i dont use full imports like: from app/web/app import app, db, but it isnt an ideal way of doing it
sys.stdout is how python represents stdout
you have ./app/app./py and ./manager.py?
python packages are looked up relative to the current working directory, not relative to the script being executed
i have a folder app with an init file inside it and a manager.py file inside it and i do the imports like this in the manager.py file: from app import app, db
but it says that it cant find the module app
Spent the whole day working on ansible and I think I'm finally close to a once command deploy of our ubuntu/django/postgres/nginx stack install
Just need to sort out redis
what is your current working directory when running this? and how are you running it?
if you are in my-stuff/app and you run python ./manager.py then you need to cd up one level. you should be in my-stuff and you should run python -m app.manager
my current working directory is the directory where the file is in, i run it in docker, first i cd to the directory then i run: python manager.py db --help
my-app/ <--- WORKDIR should be here
README.txt
app/ <--- WORKDIR should not be here
__init__.py
app.py
db.py
manager.py
and you should run python -m app.manager db --help
thanks! im gonna try it
https://docs.python.org/3/tutorial/modules.html#packages
https://realpython.com/python-modules-packages/
@heavy knot some reading for you
thanks! ill read it
/usr/local/bin/python: No module named app.manager``` im getting this now, i also tried app.manager.py
i already found the error, its working
thanks!
π
Is it possible for us to cache our dependencies in docker build?
i've been looking into this, apparently you can but i haven't tried to do it myself yet https://stackoverflow.com/q/58018300/2954547
I actually just found out how to do it myself, even using Pipenv.
FROM python:3.8-slim
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
# Let service stop gracefully
STOPSIGNAL SIGQUIT
# Copy project files into working directory
WORKDIR /app
RUN apt-get update && apt-get install gcc -y
COPY Pipfile Pipfile
COPY Pipfile.lock Pipfile.lock
RUN pip install pipenv
RUN pipenv install --deploy --system
ADD . /app
# Run the API.
CMD python launch.py runserver --initdb
If you only copy in the pipfiles before installing dependencies it will cache
Since no files in your working dir have been changed
that's not quite the same as caching, but if it works for you then it works
what about having a docker image with the "cached" stuff?
then use that "cached" image as base
Well it does cache the dependencies
Hey @muted cobalt!
It looks like you tried to attach file type(s) that we do not allow (.yml). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
I've basically copied a old version of (python-discord/bot) lint-and-test workflow.
However I'm getting ~120k lines of flake8 errors. Locally there are no flake8 errors...
I might have misunderstood, I had in mind caching Pip downloads across full rebuilds
Using build layers is totally reasonable and normal
You could probably even use a multi-stage build where the artifact is the venv that will run the app
Could, but this is already 60 times faster than our last Dockerfile π
(not a joke)
Yikes
Just gotta fix this now and I'm good π
Hey yall, I got a PyInstaller question:
Is there a way to create an executable/.app that runs my python script with command line arguments?
i.e. produce a .app that emulates running my script with added command line arguments. (the user wont input arguments, they will simply run the .app and my script will be run with some predefined arguments)
just code the CLI arguments into the script before you compile it?
that's kind of what im trying to do without making redundant files.
its to compile for different build targets. code checks the "target" variable and some features become enabled/disabled. id love to have a way to set that "target" variable in my .spec file that i pass to PyInstaller
or maybe i can ask my question this way:
is there a way for PyInstaller to supply commandline arguments (even an environment variable would do) to the script thats being compiled?
if so, I can have one .spec file per build target and that would make me very happy rn
You are probably just looking how to use makefiles
Or if more python oriented... one of its cli interface building libraries, I recommend pip install click
Just launch your pyinstaller with command from it
os.system("your pyinstaller command")
python oriented makefile, yes!
i have not heard of this module, i'll look into it. thank you!
python scripts.py build -t linux
For example for your interface
Build target could be having default value
python scripts.py build -t linux
i dont think i quite get this. does this solution not use PyInstaller?
It is just a tool to create console user interface
What would be used inside is completely your choice
On this command it can activate pyinstaller commands
but would pyinstaller create an executable that running it would be the equivalent of running a script on the command line with arguments?
to reiterate, im trying to produce an executable that itself will not take an argument, rather the executable will be the executable of script.py arg1 if you will
so that i can make
target1: pyinstaller executable with arg1 target2: pyinstaller exec with arg2 ...
Yes, that exactly what you would do
Actually you just wrote simple makefile :)
i see. lemme bang my head on it for a bit
i have the makefile, i use make
but i need to compile the same code with just one variable be different at compile time
that i couldnt achieve via pyinstaller
Click library is the same as, makefile, it just allows you to write makefile in python
With more comfortable features
gotchu. thanks!
I've basically copied a old version of (python-discord/bot) lint-and-test workflow.
However I'm getting ~120k lines of flake8 errors. Locally there are no flake8 errors...
may be you forgot to copy flake8 config file which you probably had?
if such thing exists, it was probably in your root folder
actually
and itβs in the tox.ini file
may be you have broken \n\r new line in your workflow
instead of running
run: "python -m flake8
--format='::error file=%(path)s,line=%(row)d,col=%(col)d::
[flake8] %(code)s: %(text)s'"
it runs:
run: python -m flake8
check what it is launching)
shrugs I just consider all potential choices
you said that
it runs normal locally
but not running well in workflow
perhaps it has problems with some dependencies?
in how they are installed in workflow
actually...
just make git clone of your repository to another folder
and try launching flake8 from zero
perhaps some .gitignore issue
just letting you know, i released a 0.2 version of justuse π now it's also possible to decorate functions/methods/classes etc. matching a name-pattern on import
on the auto-install front i'm a bit stuck with the actual "install" part, downloading and checking works though
oh, and you can pass in optional defaults now, that should be returned if something fails during import
so instead of
try:
import foo
except ImportError:
foo = None
you can do
foo = use("foo", default=None)
and aspectizing (remote-decorating) works like
foo = use("foo", aspectize={(use.functions, ""): log})
which would decorate all functions in the module with your "log" decorator of choice
use.isfunction*
(an alias of inspect.isfunction)
Do you guys know any library which helps me to find a line of code or a log from all the imported modules in a particular module of python. Do you know how to use grep command to do so.
https://github.com/Piston-CLI/piston-cli/runs/2801084957?check_suite_focus=true I am getting this error on a git workflow, not able to understand what that means
your main branch is protected - that means you can not directly push to it
but I supply it a token with this permissions 
Maybe this doc will help: https://github.com/stefanzweifel/git-auto-commit-action#push-to-protected-branches
@supple venture To me it seems that you maybe need to allow admins to bypass this rule: "remote: error: Required status check "Lint" is expected. At least 1 approving review is required by reviewers with write access."
But I havenβt enabled this, so admins have basically no restrictions 
I added myself to allow bypass letβs see if it works 
I have two postgres versions
- 9.6 (my data is in this version)
- 13 (empty | new)
how do upgrade the databases from 9.6 to 13 and move it to version 13?
@cloud elbow
https://www.postgresql.org/docs/current/upgrading.html
For major releases of PostgreSQL, the internal data storage format is subject to change, thus complicating upgrades. The traditional method for moving data to a new major version is to dump and reload the database, though this can be slow. A faster method is
pg_upgrade.
I recommend reading this entire page carefully
I don't have the bin directory wtf
(using saltstack)
they might be installed somewhere else
it's probably os-dependent
maybe /usr/bin
it should already be on your path
I've basically copied a old version of (python-discord/bot) lint-and-test workflow.
However I'm getting ~120k lines of flake8 errors. Locally there are no flake8 errors...
Looking at this it seems like it's definitely an issue with the caching
You need to ensure the .cache folder is excluded in your flake8 config
@muted cobalt
hello folks, I have a (private) python repo on github and I'd like to know whether is it possible to set up something like
- pyinstaller creates the .exe
- the exe is zipped alongside a .txt file
- the result .zip is marked as a release
(please ping me when replying)
Yes, you could do it with GitHub actions
looking up what that is, thank you
+1 sounds like definitely possible
https://github.com/marketplace/actions/automatic-releases
It looks like it is related to it
hmm, why is it having a dog with man as picture? π€
oh this also looks great, thanks!
with some googling it is possible to find for python
this one auto publishes to PyPi
nice
I did some googling but didn't find what I was searching for
I am googling like... "github actions <insert my combination of words>"
usually adding "release" word
the last combination I tried "github python auto release actions" and previous one as "Github actions auto making release"
so this code is in my_file.py
hkdf = cy.hazmat.primitives.kdf.hkdf.HKDF(
algorithm=cy.hazmat.primitives.hashes.SHA256(),
length=32,
salt=None,
info=None,
backend=cy.hazmat.backends.default_backend()
)```
but get an error:
```AttributeError: module 'cryptography' has no attribute 'hazmat'```
but the same code in terminal interpreter works just fine
im stuck in a terraform init loop; im just learning TF, and trying to set up a remote backend. I deleted a S3 bucket on the console and now my terraform CLI keeps me in this loop about the deleted S3 bucket...
ive tried terraform init -reconfigure and still blabbing about the deleted S3 bucket.. any way I can do a fresh restart?
β
β Reason: Unsetting the previously set backend "s3"``` is the error msg im getting
so then i run terraform init -reconfigure
tehn i get Terraform has been successfully initialized!
but upon terraform apply it shows an error about the deleted S3 bucket
I'm having troubles trying to get git to work with vs code
I have a private repo. I generated the ssh key and linked it to my github account. When I clone using git bash, it downloads just fine, but cloning through vs code just hangs forever
I'm having trouble with poetry on Windows through the git shell. It's telling me that I need elevated permissions:
poetry run pre-commit install
OSError
[WinError 740] The requested operation requires elevation
at c:\users\mark\scoop\apps\python\3.9.5\lib\subprocess.py:1420 in _execute_child
1416β sys.audit("subprocess.Popen", executable, args, cwd, env)
1417β
1418β # Start the process
1419β try:
β 1420β hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1421β # no special security
1422β None, None,
1423β int(not close_fds),
1424β creationflags,
Works fine through PowerShell. I tried looking up this issue for poetry but didn't find anything. Has anyone on Windows encountered this before?
Perhaps related, when I try to run my pre-commit hooks, one of them fails saying that node.js needs elevated permissions. Again, it works fine through PowerShell.
Might be something about your environment variables
Confirm that you can clone or fetch through bash terminal, then in that terminal , type code and hit enter to open up vs code with a Child of that bash environment
Then try git fetching or something through vs code
If it works, there you go
Thank you! When I tried git clone through the terminal this time, I was prompted to authenticate Github through the browser for git's cred manager, and after doing that, it now works through VS Code as well
Noice
this is not the right channel to post projects, you can post them on the reddit, thanks!
You can, open the git console, to see the errors/commands vscode is running behind the back, it makes debugging it easier
Sure
I was so close. When I commit through VS code, it appears that all changes commit, but opening the repository on the website shows nothing went through and changed
Look up creating a bash profile with credentials and how to point your bash terminal at the credential file
My best guess is that the hanging is related to an issue with your http proxy or https proxy setting, and the other half is that you don't have your github username and password saved in your vsc bash environment
If you got a 503 during that first vsc hang you need to set a proxy
it now downloads the repo correctly but nothing happens when I commit
Anyone can clone your repo (since its probably public) without logging in, so you need to pass your username and password to your git request via the profile when attempting to commit
it is private, the cloning didn't work earlier but now it does
committing doesn't work though
Did you forget to push to a remote after committing?
Waitaminit
I set it up on another computer and now it somehow works
thank you all who helped! π
Need some help with github permissions, the token has literally every permission it can have.
Unexpected input(s) 'token', valid inputs are ['install_url', 'nix_path', 'extra_nix_config'] I don't really know much about github actions, but that seems to be saying that token isn't a valid option, (i.e. it doesn't want a token at all), rather than that the token is invalid.
Not sure, but I think its the problem on the github runner side
actions/runner#514
ah, yeah that's probably right, didn't realise that was a warning not an error. I'm not too sure then
No worries
, I am using a token which I use to push myself (same permissions, different token) and I never got that error, so even I was suprised when I first got it. I tried to mess around with repo perms and token perms, didn't help.
any one know if its possible to set env variables in pyproject.toml
eg, i have a flask app and i want to have pyproject.toml recognize the entrypoint without me setting it with export
no, pyproject.toml by default does not have any way to set environment variables in general. you could theoretically write a program that reads env vars from it, but in the case of flask it wouldn't be easy; you'd have to invoke a different script which would then invoke flask, and at that point you might as well just use a Makefile or a shell script
i recommend using direnv https://direnv.net/ to automatically set environment variables in your dev environment
neat, will take a look
is anyone familiar with microsoft azure
go ahead and ask!
actually i wanted to create alerts for the vm
Create an alert for the server down notification and check whether it is
implemented successfully?
is there a way that i can use selenium to select a drop down list and then click one of the items from that list?
https://www.technomarket.bg/search?query=remington this is the site and i want to click the drop down list as shown in the picture, I am typing using the xpath to do this:
elemental= driver.find_element_by_xpath("/html/body/tm-root/main/tm-search/div/tm-product-filter/div/mat-drawer-container/mat-drawer-content/div[2]/div[1]/div[2]/tm-product-filter-facet[2]/div/mat-form-field/div/div[1]/div/mat-select/div/div[2]")
elemental.click()```
(i am copying the full xpath from the page of the site) but i get an error that the element is not found
any idea why?
Π’Π΅Ρ Π½ΠΎΠΌΠ°ΡΠΊΠ΅Ρ Π½Π°ΠΉ-Π³ΠΎΠ»ΡΠΌΠ°ΡΠ° Π²Π΅ΡΠΈΠ³Π° Π·Π° Π±ΡΠ»Π°, ΡΠ΅ΡΠ½Π° ΠΈ ΠΎΡΠΈΡ ΡΠ΅Ρ Π½ΠΈΠΊΠ° Π² ΠΡΠ»Π³Π°ΡΠΈΡ. ΠΡΠΏΠΈ Π»Π΅ΡΠ½ΠΎ ΠΈ Π±ΡΡΠ·ΠΎ ΠΎΠ½Π»Π°ΠΉΠ½ Ρ Π±Π΅Π·ΠΏΠ»Π°ΡΠ½Π° Π΄ΠΎΡΡΠ°Π²ΠΊΠ°. Π£Π΄ΡΠ»ΠΆΠ°Π²Π°Π½Π΅ Π½Π° Π³Π°ΡΠ°Π½ΡΠΈΡΡΠ° Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠ° ΠΠ°ΡΠ°Π½ΡΠΈΡ ΠΏΠ»ΡΡ.
1)Create two users (user01 and user02) in Azure Active Directory.
2)Make sure that both the users can login to their accounts through Azure Portal.
how do i do the second step
I want to switch my repo from GitHub to GitLab. I already changed git config --global user.name and email and added an origin with the new repo link. How do I give it my gitlab password now?
> git push origin-gitlab main
git@gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
has anyone used selenium python to automate angular apps?
Do you want to authenticate with an SSH key or with HTTPS?
I have but it's kinda painful in my opinion. Enjoyed more doing the same with cypress. Just my opinion
Right now I'm trying to do with SSH, since the other stores the password as plaintext
I was able to use gitlab option to import the repo from github, and then cloned from gitlab to a new folder. Now I'm trying to save the password/key so I don't have to type it everytime
I created a pair of keys and added the pub key to gitlab. ssh-add ~/.ssh/id_rsa
I tried that with my ssh link and it says Could not resolve hostname .. Name or service not known
now I tried ssh -T git@gitlab.com and it says Welcome
Yeah that is what I meant to use
it still asks for username and password when I type git push
Did you use the ssh link for the remote?
type git remote -v
It will list your remotes
yeah I need to change to ssh
yes now it's working, not asking for anything
thank you
You're welcome
looked at cypress this wont work on my use case since the business wont spend π
Does it make sense to dockerize a python script that needs to be portable for multiple users? Right now my setup instructions are just to clone a repo and then set up the virtualenv and install packages etc., but one person so far has had issues with python versions on their machine being all messed up. Granted that's probably a user error on their part, but I'm trying to minimize work for people to have to do in order to be able to run the script. I don't have a lot of creating Docker images experience, so my look at it makes me wonder why it would be worth it since then to run the script (from what I know) they'd have to exec into the container, no? Or is there a better way and the right thing to do is to make an image for the script?
I don't know what your target audience is, but if someone can't manage Python versions on their machine properly then trying to use Docker is probably going to be over their heads too.
If you create your image with an entrypoint defined, they would just have to start the container and then stop it when they are done. They don't need to exec into it.
You're trying to minimise work for users, but keep in mind that if you use Docker, then that's just another thing they'd have to install (unless they wanna go the manual route like your original instructions).
I suppose you could offer Docker as an alternative.
everyone that's using it should already have docker installed
it was my manager that's python versions were messed up, he doesn't really do dev work anymore and didn't feel like fixing it when i thappened I guess
so it just kind of begged the question if it's portable enough I guess
it's open source/free to use - https://github.com/cypress-io/cypress
they offer additional features that you don't necessarily need/want/afford/etc
Well okay, you can make a Docker image for it. They'd just need to run one command to start the container.
but if the script takes arguments would those arguments be passed as run arguments then?
Yes, you can pass them to docker run
Though I think if you pass arguments you have to specify the command to run
gotcha.. will keep as a consideration
seems kinda like unnecessary work to me, would prefer to have a jump host we have tooling on rather than relying on personal machines
When git push is run, which remote does it use by default?
Permission denied <repo> to username
I made a new github account and tried to git push origin master it gave me this problem, how to solve?
Please ping me if you know the help.
Origin by default, but if you checkout a branch from a remote, then that branch will remember which remote it came from and git push will respect that.
That can also be changed with git branch -u ...
bump
I'm working on a tool that checks your email or (emails) if they are pwned, basically it works by seeing the error code of a website and if it's error code 200 it says a certain thing and if it's error code 404 it says it's not pwned, basically, I'm getting an error 403, and I tried Proxies, a useragent, etc., and it's just giving me a syntax error with the headers for some reason, and an error 403 without the headers, but with the proxies, somene help! π€
@nimble mango doesn't troy hunt's site have an api? i suspect that haveibeenpwned forbids scraping and takes measures to prevent it, hence the 403
and circumventing that would be against our server rules to discuss
I believe their API costs money to use
And I don't really wanna pay for an api when I can just use the website
but it was gonna be cool to have a loop just checking my emails
btw, i haven't really mentioned it (since it works pretty much flawlessly and i didn't need any help with that), but justuse can safely import code from an URL, which i imagine could be nice for deployment
i'd be curious if i could tag a claim of "unhackable infrastructure" on it, even, maybe someone is interested in testing it π
i'd guess that a system under attack would rather collapse than get corrupted
Anyone here got experience with creating docs/docstrings for python+Doxygen?
I'm using Doxygen+doxypypy (because I have to) but I am having a hard time using e.g., the "Attributes" tag to define public class attributes
Any recommendations for a tool that handles processes?
So I decided to use a linter (with VSCode) again and settled with flake8. I've cleaned up my file as much as I could, but can't get rid of error no newline at end of file flake8(W292). The end of my file looks like this.
# TESTING
if __name__ == "__main__":
app = qtw.QApplication(sys.argv)
mw = ConversationsList()
sys.exit(app.exec())
# end of file
Searched it up and found this article, https://www.flake8rules.com/rules/W292.html , that did not really help though. What am I doing wrong?
Files should end with a newline.
what do you mean by "processes"? interacting with the operating system (killing processes, etc.)? running other programs from within python? running multiple python processes ("process parallelism")?
@wintry iris press "enter" at the end of your file and try again?
it's possible that vscode is configured to remove trailing newlines
yea i mean interacting with the operating system (killing processes, etc.)?
it worked, thank you
Can I get pycharm to ignore in-file annnotations and use stubs for type hints? It recognizes the stubs but the normal annotation overrides them which makes them useless
There is to many tchat for help I will put my problem here. Well i got a python question that even Stack O didnt answer ... I create a private chat secured by AES with Tkinter. It went perfectly even on Android with Pydroid on Google play. Here is my problème : I want to close a Android keyboard with python.
I want to click on the products in the basket one by one and get their information, but I can enter the first one, but not the others in Selenium.
how does one move one folder in github to another folder, preferably though the website UI?
might be a dumb q but: I am learning terraform and aws, i am fiddling around making a new vpc, subnets, gateways, security groups for my redshift vpc. I eventually want to access redshift via my terminal, what should i be editing ? the security group ingress/egress?
like do i need to add an extra ingress rule to account for me eventually accessing redshift via my terminal?
if so, what would the rule be
I think it's Port exposure.
Your vpc security groups should allow connections on the ports necessary if you need to access the vpc and redshift
For configuration changes, create start delete list get describe etc you use the awscli or boto3 to pass instructions, and that doesn't need any modifications to the security groups
If you want to do configuration changes "properly", also set up an assume role that your desktop client can assume via Sts and give that role the necessary permissions to redshift (and ec2 and s3 and so on)
You should still be careful about exposing your vpcs to the Internet, so look up how to do that securely
Really helpful! I will try this out and good info about cli
thank you
Sure. I do this for work so @me if you need any help
BTW if you're doing it in python just use botocore and boto3, once you get advanced enough to automate modifications to your consumed aws services, then boto3 requests are much simpler to configure and send automatically
I use Sphinx for same purposes and loving it
It has this feature named as autodoc
Iβm making the resources on terraform iunno if thatβs the same thing youβre explaining. Terraform to build the resources, and then afterwards, copy a large CSV from S3 into redshift
So Iβm not really using Python/boto3 unless Iβm missing a use case
i am following this with a few of my own steps: https://medium.com/cloud-tidbits/terraforming-and-connecting-to-your-aws-redshift-cluster-16f93ddd41cc
he accesses redshift through the console, i wanna access my redshift instance via my terminal
when you say "access redshift" you just want to run queries and get some data back?
if so, i've used Redshift's data api with decent success: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/redshift-data.html
this can be done via aws-cli or through boto3.
yup, query, make tables, load them etc
ohhhh that looks promising ^
so if I have aws-cli properly configured I can just make use this boto3 API and not have to do any security/port configuring?
Ah, yes, the security port configuring is if you are making requests from outside the aws environment
Since you're making requests using the aws sdk, no need to mess around with that
Hey guys, can anyone tell me how to generate an executable that can be run on Linux and Mac OS from Windows using PyInstaller or Nuitka?
Thanks for the help ππ½
scheduler:
image: 'python:3.8-alpine'
container_name: 'scheduler'
build: '.'
depends_on:
- db
command: cd app/reddit && python -m app.urs.mainscrape
ERROR: for scheduler Cannot start service scheduler: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "cd": exe
cutable file not found in $PATH: unknown
hey, does someone know i can make this command work?
which command you are using to launch it
well, anyway.
just add path in your docker file
WORKDIR /app/follder/project
then you will be able removing "cd" command
or actually...
just debug the container with docker exec command
scheduler:
image: 'python:3.8-alpine'
container_name: 'scheduler'
WORKDIR: '/app/reddit'
build: '.'
depends_on:
- db
command: python -m urs.mainscrape
docker-compose up -d --build
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
Unsupported config option for services.scheduler: 'WORKDIR'
im getting this error, i think it isnt working because im using docker-compose
that doesnt work i think because the container doesnt get created
WORKDIR /app/follder/project is to be put in your Dockerfile
i have 2 py files that needs to be ran in the same directory, how would that work? because ill need 2 dockerfiles in the same directory
You can name your dockerfile anything and pass it in on build parameter
build:
dockerfile: xx
oohh okay thanks! im gonna try it
i tried it like this:
services:
flask_app:
container_name: 'flask_app'
build: '.'
dockerfile: Dockerfile_flask
environment:
- FLASK_APP=app.py
- SQLALCHEMY_DATABASE_URI=sqlite:///database.sqlite
ports:
- "8001:5000"
depends_on:
- redis
- db
scheduler:
container_name: 'scheduler'
build: '.'
dockerfile: Dockerfile_scheduler
depends_on:
- db
command: python -m urs.mainscrape
but im getting this error:
ERROR: yaml.parser.ParserError: while parsing a block mapping
in ".\docker-compose.yml", line 6, column 5
expected <block end>, but found '<block mapping start>'
in ".\docker-compose.yml", line 8, column 7
i think it has something to do with the '.' on build, but if i remove it it says it doesnt have an image or build context
would this be the best channel for discussing IDEs?
I am not sure about that.
@heavy knot this might be a yaml parsing error, try quoting your commands and such
oh yeah this is wrong
build: '.'
dockerfile: Dockerfile_flask
that's not valid yaml
build:
context: '.'
dockerfile: Dockerfile_flask
``` @heavy knot it should be this
I don't think quotes are needed. https://docs.docker.com/compose/compose-file/compose-file-v3/#context
they aren't, yaml lets you omit them
but yaml also interprets things like true as a boolean, so it's good practice to defensively quote yaml imo
I see
i have an error
oh god, yes 
t = subprocess.run(["dir"])
it it give
File "C:\Users\kushal\Documents\com.py", line 3, in <module>
t= subprocess.run(["dir"])
File "C:\Users\kushal\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\kushal\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\kushal\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
[Finished in 2.1s]
File "C:\Users\kushal\Documents\com.py", line 4, in <module>
t = subprocess.run("dir")
File "C:\Users\kushal\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\kushal\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\kushal\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
[Finished in 1.8s]```
no it also give error
I need invite tracker
I have 30%
Need join message cfg
And joinmessage cfg
And leave too
@heavy knot dir might not be a binary, it might be a shell built-in. try subprocess.run('dir', shell=True)
Hi I have a Project repository which has 2 projects frond-end and back-end
Projcet
How can I deploy on Heroku?
backend is a flask api, front end is a reactjs app
anyone here deploying to Azure? I'm confused as to how my requirements.txt libs are supposed to be deployed
either by the azure devops build pipeline zipping them up, or the azure web deploy deploying them?!
Got a somewhat non-Python question for you guys:
I am working on a semi-private project that I would like to remain visible to the open Internet.
However, I would also like to make sure that forks, pulls and clones can only be done by a group of authenticated users. This is to ensure that users may access the repository but can only make meaningful use of it if they agree to a set of Terms and Conditions.
Has anyone ever tried something like this? Any thoughts on how to do this in GitHub or GitLab?
you can't feasibly restrict people from illegally cloning a public repo, but you can do so by license
any law-abiding person needs to adhere to the given license, so you could simply state your conditions in there
you can't prevent people from violating it though, which lawyers are for
(even if one clicks on "i agree to the license conditions" it could be a lie)
maybe gitlab has support for this. alternatively, you can keep the git repository private but post source tarballs for every release
@tawdry needle but that doesn't hinder someone with access to copy it locally and then fork etc. whatever they like..
Aye, has anyone managed to make sense of Tox's platform conditionals? I'd like to have a single testenv execute one of two commands based on the OS, but I'm quite lost.
hello, do you know any good library to modify pdf and docx documents
Hello, I wanted to know if anybody tried a nvidia container with a different version of CUDA
I need to practise navigating around Linux because I'm taking over my company's machine image release pipeline shortly, what would you guys recommend for practise on my own time
I'm on windows
Docker with Linux or Linux partition
Install for yourself ubuntu 20.04 desktop, it is beginner friendly
Quite comfortable for devops stuff
Hey, could someone give me an explanation on what git rebase does?
I've tried reading docs but I'm still a little confused
It lets you change the base commit, for example if your main branch has commits a b c and you have a feature branch that's based on a, then rebasing would let you change the base commit to c (you get all the changes from main without a merge) and then it copies the existing commits on top of it.
Or with an interactive rebase you can manipulate the history manually, you can change commit messages, re-order, squash them etc.
Oh I see, thank you!
Cheers man
Hello All, I thought I would share another tool you can use to visualize your data, let me know what you think
https://github.com/codemation/easycharts
hey
Everwhere on the Nginx site, it takes about free trials
Is there not a free tier of some sort?
what?
Nginx is free and open source, but there is a paid enterprise version with extra features
Useful tools, examples, and other learning resources for getting started with NGINX.
Ty
@heavy knot what is the full traceback? It seems like something is trying to resolve a cache file at ~/.cache.json
alright, the error is that the home folder doesn't exist
Yeah
You can either create it first and use another location
!d pathlib.Path.mkdir
Path.mkdir(mode=0o777, parents=False, exist_ok=False)```
Create a new directory at this given path. If *mode* is given, it is combined with the processβ `umask` value to determine the file mode and access flags. If the path already exists, [`FileExistsError`](https://docs.python.org/3/library/exceptions.html#FileExistsError "FileExistsError") is raised.
If *parents* is true, any missing parents of this path are created as needed; they are created with the default permissions without taking *mode* into account (mimicking the POSIX `mkdir -p` command).
If *parents* is false (the default), a missing parent raises [`FileNotFoundError`](https://docs.python.org/3/library/exceptions.html#FileNotFoundError "FileNotFoundError").
If *exist\_ok* is false (the default), [`FileExistsError`](https://docs.python.org/3/library/exceptions.html#FileExistsError "FileExistsError") is raised if the target directory already exists.
lol I'm here now
You need to do FOURIER_DIR.mkdir(parents=True, exist_ok=True) @heavy knot
Anyone know what this means? I am able to ssh just fine through terminal. But in VSCode I keep running into this.
bash command not found, do you have /bin/bash on your machine? π
On my local machine or the remote machine?
@eager cedar on my local machine I'm using zsh but the remote machine I'm connecting to uses bash
I don't use vscode, so I have 0 clue about the implementation and use of that feature
but seems to me like one should check if which bash on both machines I guess.
@eager cedar What editor do you use to connect to a remote machine?
why would I use an editor for that?
@eager cedar It's tough to code in vi or a command line editor
Do you absolutely need to code on the remote machine?
@eager cedar Yeah unfortunately, I can't really replicate the environment right now because the remote machine is a raspberry pi.
I use vim so I don't have that problem, but one should only have to code on a remote machine in very rare occasions
alright, I would just use a container technology if you have environment differences.
What kind of project are you working on? Maybe I could be more specific in my suggestions then.
@calm tapir
@eager cedar Yeah might just create a docker image tbh. It's basically a robot that runs on a raspberry pi. And I need to run a Python script on it. I could just write the code locally and keep copying and pasting it into the raspberry pi for debugging but that is a painful process each time.
you could also just rsync automatically on save.
@eager cedar Yeah that is definitely an option. I was also thinking of using git but I don't want silly commits on my account.
I need help with selenium
Private repos are free on github if thatβs an option
Sup, need some help I am working on a project with starlette, a fairly simple one, have it private sourced on github right now as it is for school, I am using a similar setup like pixels, but I get this error: https://paste.pythondiscord.com/yadatiliso.rb
Dockerfile
docker-compose.yml
table admins does not exist
migrate db, or something like that
or create db and tables π
I do that alembic upgrade head in CMD
docker compose create volumes as root
cannot make changes to the mounted files made from shell in docker container as a normal user
Hey! I have my code and wanna add that to my git hub. I created new repository (default) and following instructions got this
I need copy this file to git folder π€
Solved!
change the USER in the dockerfile maybe? or is it because docker itself was run with sudo?
You can make a user with the same UID as the host user (default is 1000)
RUN addgroup --gid 1000 test_group
RUN adduser --uid 1000 \
--gid 1000 \
--home /home/test_user \
--quiet \
--disabled-password \
--ingroup test_group \
test_user
@eager cedar docker doesn't "translate" UIDs at all?
Define translate in this context
but think about it this way, the container doesn't know anything about your hosts users, so how would it even begin to "translate" UID's to something that doesn't conflict with UID's on the host?
Not sure if that's what you are reffering to :-)
suppose my UID in the container is 1234 and the docker daemon is running on the host as 1111. if a program inside the container writes a file to a volume, will the UID of the file be 1234 or 1111 or something else?
1234
I am pretty certain, but let me check 
seems like it's just owned by root 
I tried to make a docker compose example.
FROM ubuntu:latest
RUN addgroup --gid 1000 test_group
RUN adduser --uid 1000 \
--gid 1000 \
--home /home/test_user \
--quiet \
--disabled-password \
test_user
USER test_user
CMD ["tail", "-f", "/dev/null"]
docker build -t meme .
docker-compose.yml
version: "3.8"
services:
ubuntu:
image: meme
container_name: ubuntu
command: tail -f /dev/null
volumes:
- ./kek:/tmp/kek
@tawdry needle
Produces:
drwxr-xr-x 2 root root 40 Jun 21 20:55 kek
because I ran the the docker command as root I presume.
ok that's what i was wondering
Does anyone here have experience with migrating a private pypi to Artifactory?
can anyone recommend a dependency compatibility checker resolving transitive dependencies?
i have a small issue with use() i'd like to discuss.
use(use.Path(..)) can load from arbitrary relative or absolute paths, which works well because it changes the CWD for each import (and back)
it also works well in jupyter, because you can cd around, but
F:\Dropbox (Privat)\code\justuse> python .\src\use\test4.py with a relative use(use.Path()) inside will invariably fail because the envocation doesn't change the CWD
so now my predicament - do i need to look at the sys.argv to determine whether or not i need to chdir or is there some cleverer way to make the right call?
using the CWD internally is very elegant and ensures that also relative imports just work, so abandoning this approach would make things a lot more complicated overall
nvm, i think i found a solution.. __import__("__main__").__file__ should do the trick
why do you need to change CWD?
maybe instead you can temporarily add stuff to sys.path, or maybe there's a way around sys.path entirely using the "loader" mechanism
@tawdry needle sys.path is a hack, i noticed somewhere in my deep dive into the import machinery a comment that basically said "we really should use cwd everywhere"
Even for site packages?
and yeah, if CWD is changed correctly, it all works out perfectly
not sure about site packages, i haven't really gotten into auto-install that far yet
but yeah, if the cwd is updated recursively and reset correctly, even relative imports work in concert with use(use.Path())
at first i didn't even expect to have it both hand in hand
but now i kind of take it for granted π
I have a git branch with 7 commits, and I'd like to merge it all into the same commit (sort of like squashing a PR, but on the same branch). How would you do such a thing?
Use an interactive rebase and select squash or fixup for the commits.
git rebase -i HEAD~7
Then you can squash them by adding s instead of the pick in all the commits you wanna squash down
Then it will open the commit file in your configured editor
Thank you both so much!
Np, and yeah remember to force force after commiting, git push origin my_branch --force
otherwise git would mess up your commit history
Wow good to know
I am usually doing in this situation git push --force-with-lease, what would be the difference?
while remaining on the secondary branch where I squash the stuff
If your branch is set to track the remote then you can omit the remote and branch name from the push command
And force with lease is a variation of force that aborts if the remote has commits you don't have locally
i.e. --force is serious danger zone material and --force-with-lease is not
I didn't know about --force-with-lease, thanks!
It can still be dangerous if you're keeping your local repo up to date with git fetch (but not actually pulling those changes).
What's the best way to keep your local branch up to date with the master (say, after merging a pr)
I've been doing fetch master then rebasing my dev branch
Git pull origin master?
git pull --rebase origin master unless you have git configured to rebase on pull by default.
I had the oddest thing where one of my interns who swears she has been doing it was still 1.5k commits and several months behind the remote master somehow
Ahhhh okay. Probably doing that without having auto rebase configured
A feature branch living long enough for 1.5k commits on main is quite concerning.
I mean in the sense that she should be aiming to merge her changes more frequently into the main branch. But I've not worked on gigantic projects so what do I know. Maybe some stuff legitimately has to sit that long in a separate branch.
Yup
the only downside with rebasing off master (as opposed to merging master) is that conflict resolution can be extremely gnarly if your branch refactors existing code
resolving merge conflicts is one thing, resolving rebase conflicts is a whole different animal
I local branch, here is it a feature branch or the main branch. I personally never do any changes to main branch so I just call git fetch upstream; git reset --hard upstream/main. And for feature branches what mark said,or the update branch button the github PR
Ah yeah we don't either, everything has to be done via pr.
Gotcha on the rest, thanks guys π
Too right yeah. If it happens I usually give up trying to resolve it, move whatever change I have out into a seperate folder, wipe my branch clean and just paste stuff back in like a barbarian
bar bar bar ME AM MAKE CODE GUD
I should put this on a bumper sticker
I, Caveman
Lol, pycharm makes it simpler tho, not easy just simpler
the next big thing i'm going to tackle in justuse will be auto-installation, i guess.. then it also should be possible to install and use different versions of the same package in the same codebase π
any input on how that could be achieved?
downloading should work, but i'm not sure yet how packages are actually installed
i am thinking of a json file that keeps record of all the packages that are installed somewhere on the system with their versions and hashes, does something like that already exist?
{name: [version: "path": str(Path), hash: str(sha256)]} something like that
basically the pypi metadata, just locally with a pointer to the path
that would make it possible to share packages where possible and have diverging dependencies at the same time
hmm.. then i could lightly monkey-patch the import machinery to check the dependency registry on attempted import and chdir to that path
making messing with sys.path obsolete
and people could hack the registry if they moved packages etc. while at the same time integrity would be ensured via hash
any suggestions where that registry file could be put as a default?
$XDG_DATA_HOME/python-justuse maybe
or $XDG_CACHE_HOME if it's not "bad" to delete the data
This seems ultra crazy
@wooden ibex how so?
Mixing imports like that, when you are monkey patching core parts of compiler, you might want to reconsider your approach
sys.path is a hack that simply got out of hand, having a proper registry of installed packages is much less crazy, imo
and i said "light monkeypatch", it would only need to wrap the imports to chdir to where it needs to be
since the import machinery works much better if the current working directory is properly set
it wouldn't require changing the whole machinery
just a nudge to look in the right place
@tawdry needle okay, i'll start with that π
@wooden ibex https://github.com/amogorkon/justuse/blob/main/README.md you'll find much more crazy stuff there π
but honestly, i find https://macropy3.readthedocs.io/en/latest/index.html much more crazy than any of that
heh
besides, it's an officially supported mechanism called import hooks https://www.python.org/dev/peps/pep-0302/#id28
meta hooks is probably the thing i'll need to look into, since it's called at the beginning of the import process
runs away screaming
lures Rabbit in with fresh carrots
Nope
fresh meat?
Nope
π¦
I donβt want anything near this, this isnβt DevOps, this is crazy dev
No
can anyone recommend a licence compatibility checker resolving transitive dependencies?
hey guys,
I don't know if this is the right channel, but I want help with matplotlib. If anyone knows how to change the colors of the numbers please help me thx π
personally, I don't see anything crazy about taking control of the import process long enough to ensure you get a specific module (version) loaded while not disrupting resolution for the rest of the session
?
For Docker and docker-compose users, when you lauch a command with docker-compose, do you have errors saying x file could not be found despite having the directory configured?
Ex. when you launch docker exec on a Django app, with ls
You have the manage.py file in it
But when you use command: python manage.py runserver 0.0.0.0:8000 it says manage.py not found. Why is that?
@wooden ibex btw, i'm not even sure i need to fiddle with meta_path at all, no monkey patching required
less crazy dev, more devops π
pip insists that only ever one version of a package is installed, so i can just put the other versions in an extra dir and let pip do its stuff without interfering
if someone wants to have different versions of the same package side by side in the same code, they'd go through use(), which will just handle those version-pinned, well defined versions with no guessing
so, if someone doesn't care about the exact version and wants to go the classic way, they can do that still with no change of behaviour
can you show the dockerfile and docker compose file?
FROM python:3.9.5-slim
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
WORKDIR /app
RUN apt-get update &&\
apt-get install -y binutils libproj-dev gdal-bin
COPY requirements.txt .
RUN pip install -r requirements.txt --no-cache-dir
COPY . .
and docker-compose:
version: '3.8'
services:
db:
image: postgis/postgis
container_name: db-postgis
env_file:
- ./db/.env
networks:
- backend-network
ports:
- 5432:5432
volumes:
- db-data:/var/lib/postgresql/data
backend:
restart: on-failure
env_file: ./backend/.env
build: ./backend
expose:
- 8000
ports:
- 8000:8000
volumes:
- ./backend:/backend
command:
- ./startapp.sh
container_name: django-backend
depends_on:
- db
networks:
- backend-network
- frontend-network
frontend:
build:
context: ./frontend
dockerfile: ./Dockerfile
args:
environment: development
status: stable
expose:
- 3000
ports:
- 3000:3000
container_name: react-frontend
env_file: ./frontend/.env.development
volumes:
- ./frontend:/frontend
networks:
- frontend-network
networks:
frontend-network: {}
backend-network: {}
volumes:
db-data: {}
The Dockerfile is for the Django app
just to be safe, i always use absolute paths on the RHS of COPY
COPY . /app
and what is in startapp.sh?
and one more question: what's the structure of files in .?
#!/bin/bash
# Wait for db
echo "Waiting for db.."
if [ "$DATABASE" = "postgis" ]
then
echo "Waiting for postgis..."
while ! nc -z $SQL_HOST $SQL_PORT; do
sleep 0.1
done
echo "Postgis started"
fi
# Runs the server
echo "Running Django server"
python manage.py runserver 0.0.0.0:8000
and you're saying that you can do docker-compose run backend ls /app and you see manage.py there, right?
./backend
ββββapi
β ββββmigrations
ββββcontrol
β ββββ.mypy_cache
β ββββ3.9
β ββββcollections
β ββββcontrol
β ββββimportlib
β ββββos
β ββββ_typeshed
ββββusers
ββββmigrations
Yeah i can use docer exec backend ls and it shows the contents
Including manage.py
I have a migrate.sh script but I can't trigger it using ./migrate.sh
./backend is the working directory where Django is located
.
βββ Dockerfile
βββ Dockerfile.prod
βββ api
β βββ __init__.py
β βββ admin.py
β βββ apps.py
β βββ fields.py
β βββ filters.py
β βββ migrations
β β βββ __init__.py
β βββ models.py
β βββ serial_fields.py
β βββ serializers.py
β βββ tests.py
β βββ urls.py
β βββ views.py
βββ control
β βββ __init__.py
β βββ asgi.py
β βββ settings.py
β βββ urls.py
β βββ wsgi.py
βββ manage.py
βββ migrate.sh
βββ requirements.txt
βββ startapp.prod.sh
βββ startapp.sh
βββ users
βββ __init__.py
βββ admin.py
βββ apps.py
βββ forms.py
βββ managers.py
βββ migrations
β βββ __init__.py
βββ models.py
βββ tests.py
βββ urls.py
βββ views.py
ok, i see
...i have no idea
lol, sorry
weird
you'd expect that to work, try deleting all the containers and images then starting over from scratch π€·ββοΈ and try using absolute paths with COPY just in case
I have no idea if it's because the control folder has a different name from backend
Normally it shouldn't be the case
Yeah it shouldn't as this repo https://github.com/testdrivenio/django-docker-traefik names its project differently
I tested them and it works
ask question, do not ask to ask
okay, RFC: let's say, there is ~/justuse-python with a config.ini, registry.json and usage.log and a /packages subfolder, which is used as a default, but can be arbitrarily set in the config. all installed (whether by pip or auto-installed or otherwise) packages are registered in the registry to look up during runtime. if you use() a package with a specified version, it is looked up, and if not available, downloads the zip from pypi, imports it and writes the compiled code to disk, discarding the unzipped, uncompiled sourcecode next opportunity. this should allow classical imports and pip to work in parallel with use() without interferance
could there be any problems with this setup?
how would you control the requirement jupyter labextension install jupyterlab-plotly@4.14.3 ?
I can't add this to my requirements.txt file, so I'm not sure where that should be placed.
(ping me if you respond please)
which file permissions should i give the registry etc? i guess 777 is out of question, but what should be preferred?
you can't really have pip managing non-python dependencies. if your project requires things other than packages from pypi, you'll need some other way to specify
yeah I know pip can't which is why i asked that question π¬
sorry if it was unclear
conda is one option, but even then jupyterlab itself might be in a different environment from the kernel (although in this case it probably shouldn't be)
another is just a build/setup script
hey @tawdry needle any ideas on my suggested auto-install system?
let's say you use("numpy", version="3.0.1", auto_install=True, hash_value="98f98df.."), it would download the package, install it into ~/justuse-python/packages/numpy-3.0.1.. - out of the way of pip and classical imports with the location with other metadata put into ~/justuse-python/registry.json for quick lookup during runtime
Soooooo tl;dr of what i wanna do:
I wanna automate some parts of gitflow so when I push to master/a pr is merged i want those things to happen:
get the version from the last commit(s)
ie when the last commit is Merge from "release/v2.3.0" the version is v2.3.0
or when the last one isnt a merge it gets the last merge and then increments based on the feat and fix commits
use that version to create a tag
use that version and the last commits to create a gh release with the changelog generated from the commits
make a sentry release
the sentry release is easy i just need some way to provide it that info
the rest isnt so much
that way, use() will enable fully self-contained code, with no venv or external tools needed for dependency management
but it will actually make it easier for external tools to analyse and make updates, for instance an IDE could provide those
while not getting in the way of pip or import, if someone prefers those
okay so
I'd use a python script to determine if the commit matches
if it does, output a string, and then you can check that using run conditionals
and then you can also use that to output v2.3.0 or whatever
yeah thought so as well, but i havent found a way yet to set variables during a run
then you can use one of these https://github.com/softprops/action-gh-release to do the actual release
uhhhhh
so
A workflow is a configurable automated process made up of one or more jobs. You must create a YAML file to define your workflow configuration.
from python, you need to print a string like
::set-output name=is_release::true
::set-output name=release_tag::v2.3.0
then github will pick those up, and you can use job outputs
you can have a release job and only run it if is_release is true using https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif
A workflow is a configurable automated process made up of one or more jobs. You must create a YAML file to define your workflow configuration.
then inside that job you can use release_tag for sentry / gh release / etc
i uhhh
hm I might have a thing internally somewhere where I use set output from a py script
https://gist.github.com/jb3/0ed9a4569006751b1bd7be28076e3607 @grand gale might have a little bit of use as reference
but you can also just set the manifests from python
@deep estuary so smt like this should work?```yaml
name: Lint Kubernetes manifests
on:
push:
branches:
- master
- ltr/v*
jobs:
getvars:
name: Gets the neccecary vars for the following actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get the release version and changelog
run: |
version=$(python $(curl the script))
echo "version=$version" >> $GITHUB_ENV
echo "changelog=$(python $(curl the script))" >> $GITHUB_ENV
git tag -a $version
git push --tags
sentry_release:
needs: getvars
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: getsentry/action-release@v1.0.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: sentry_org
SENTRY_PROJECT: project_name
with:
environment: production
version: project_name@${{ env.version }}
gh_release:
needs: getvars
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ secrets.GITHUB_TOKEN }}
draft: true
tag_name: ${{ env.version }}```
I don't think it'll be in env, will it? Also you need to ensure there is a tag before pushing a tag
what dont you think will be in env if you mean the version and shit theres this:
https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
the tags are pushed in getvars but im overworking that
You can use workflow commands when running shell commands in a workflow or in an action's code.
name: Release Versions on Several Platforms
on:
push:
branches:
- master
- ltr/v*
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Get the Release Version and Changelog
run: |
echo "release_version=test" >> $GITHUB_ENV
echo "changelog=test" >> $GITHUB_ENV
- name: Push the Release to Sentry
uses: getsentry/action-release@v1.0.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: sentry_org
SENTRY_PROJECT: project_name
with:
environment: production
version: project_name@${{ env.release_version }}
- name: Create a Tag with the Version
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.release_version }}",
sha: context.sha
})
- name: Create a Release Draft
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ secrets.GITHUB_TOKEN }}
draft: true
tag_name: ${{ env.release_version }}```
so this should work
the env shit is tested and works, the other shit not yet
fucking yeah that shit works (with some edits
)
Hey all - playing around with GitLab, what's the most appropriate way to roll out source code changes to my server? GL CI/CD action that SSH's to my server and pulls the most recent changes from the master/main branch?
That's a perfectly valid solution if you don't have any (too) fancy setup with Kubernetes or similar
Perfect, thanks @warm pollen
No problem!
Also don't forget to generate a new individual ssh key that only has access to the required resources, you wouldn't want someone to gain a root access on your server in case of a leak
how do you get it connected to your server?
i assume your server is publicily accessible?
Good point @velvet spire , itβs not publicly available.
Any reason you've not mentioned docker?
no reason, depends on your intended usage i guess
@deep estuary
Yeah, I don't think I have much intuition for one over the other.
When searching stuff like conda Vs docker a lot of stuff comes up (on threads or whatever) simplifying conda to a requirements alternative, but conda goes further than pip doesn't it?
I guess idk where the limit of conda is, and whether docker "takes over" at that point. I'm also not sure if one should prefer conda over docker if it's possible to use it, or whether it's more subjective
Hi guys how are you doin??I don't know if it's the right channel but am having some problem installing mysqlclient==1.3.10 via pip3 on ubuntu 20.04 (with python3.4.3),any ideas ?Thanks
I would like to know how could I automate the video uploading process of a local video on my pc, to Youtube channel specific playlist (based on the name of the video file being uploaded).
Example: videoSam.mp4 goes to Youtube playlist "Sam", while videoFrodo.mp4 goes to Youtube Playlist "Frodo".
Is that possible?
@deep estuary if you by any chance are interested in automatic release action heres the one i use atm:```yaml
name: Release Versions on Several Platforms
on:
push:
branches:
- master
jobs:
getversion:
name: Get Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Git Version
id: version
uses: codacy/git-version@2.2.0
with:
prefix: v
dev-branch: develop
sentry:
name: Create Sentry Release
needs: getversion
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Push the Release to Sentry
uses: getsentry/action-release@v1.0.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: org-name
SENTRY_PROJECT: project-name
with:
environment: production
version: project-name@${{ needs.getversion.outputs.version }}
settag:
name: Create Git Tag from Version
needs: getversion
runs-on: ubuntu-latest
steps:
- name: Create the Tag
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ needs.getversion.outputs.version }}",
sha: context.sha
})
releasedraft:
name: Create a Github Release Draft with the Changelog
needs:
- getversion
- settag
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Build Changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Draft
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.changelog.outputs.changelog }}
draft: true
tag_name: ${{ needs.getversion.outputs.version }}```
nice one
the one CI/CD flow where I could use this uses Jenkins 
rip
can someone - define for me - tools and devops
sorry in drunk
mmmmmmm - how about a custom interface to talk to chips on a breadboard via python
@deep estuary help, im getting way too much into ci/cd
lol
docker lets you encapsulate an entire OS, while conda "only" deals with software dependencies. docker is probably better in general for isolating the dependencies of standalone applications, and much better for deploying software. there's nothing stopping you from using conda inside the docker container!
should i use IoT platforms or just access a website's api itself?
if a user wants to auto-install something via justuse and they try use("stuff", auto_install=True), it should raise an exception and give proper advice, but also info on the package they are attempting to install in order to avoid malicious packages. what is important info a user should get at this point to decide on whether or not they are trying to install a malicious package?
i'm thinking number of downloads, what else?