Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
I am trying to copy .git folder of private repo of any user when access token is provided using python. However, I could not be able to download it. I found bash script to download the file but I wanted to retrieve only .git folders. This is what I was trying
python script
TOKEN = "tokensoicanaccessprivaterepo"
OWNER=""
REPO=""
API_URL=f"https://api.github.com/repos/{OWNER}/{REPO}?access_token={TOKEN}"
req_json = requests.get(API_URL).json()
# git_url = req_json['ssh_url']
# git clone https://${TOKEN}:x-oauth-basic#github.com/{OWNER}/{REPO}.git
os.system(f"git clone https://${TOKEN}#github.com/{OWNER}/{REPO}.git")
the way I am doing asks for password event after providing personal access token with repo and user scope while cloning.
I have looked into various resources but I did not find the way to copy '.git' folder of private repo of any user with the github provider token.
UPDATE
scope
In order to make a clone without working directory, use --bare:
git clone --bare https://{TOKEN}:x-oauth-basic#github.com/{OWNER}/{REPO}.git
Also, as pointed out by you in the comments:
there is a simple typo in the command which I could not notice. There should not be $ before {TOKEN} as I am using f string.
And finally, ensure that your access token has the repo scope.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am new to GitHub: I have uploaded a django project without a .gitignore file and GitHub Community banned my account.
That is why I need to know how to use a .gitignore file as well as adding a license.
Recreate your django project locally, initialize a new local git repository in init (git init .), and, before doing any git add/git commit, add:
your .gitignore (you can copy the Django one)
your LICENSE file (chose one of those)
Add and commit locally.
Then create a new GitHub account, a new empty GitHub repository.
Go back to your local repository and:
cd /path/to/local/repo
git remote add origin https://github.com/<NewAccount>/<newRepo>
git push -u origin master
You can then see "Where to store secret keys DJANGO" for managing your secret key.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I want to write a small Python dummy project:
print('Hello world.')
... in a file called hello.py.
Next: I want to make this a small dummy project at github.
After creating a virtual-env (via PyCharm) I have these directories:
./foo
./foo/venv
./foo/venv/lib
./foo/venv/lib/python3.6
./foo/venv/lib/python3.6/site-packages
./foo/venv/include
./foo/venv/bin
I want to store my small project in git and upload it to github later.
Are there (official) docs how to start a new project after creating the virtualenv?
If I understand your question correctly, I believe this is what you are looking for:
How to create a repository in github:
In the upper-right corner of any page, click , and then click New
repository.
In the Owner drop-down, select the account you wish to create the
repository on.
Type a name for your repository, and an optional description.
Choose to make the repository either public or private. Public
repositories are visible to the public, while private repositories
are only accessible to you, and people you share them with. For more
information, see "Setting repository visibility."
When you're finished, click Create repository.
Creating a repo
Adding an existing project to a repo:
Open Terminal.
Change the current working directory to your local project.
Initialize the local directory as a Git repository.
$ git init
Add the files in your new local repository. This stages them for the
first commit.
$ git add .
Adds the files in the local repository and stages them for commit.
Commit the files that you've staged in your local repository.
$ git commit -m "First commit"
Commits the tracked changes and prepares them to be pushed to a remote repository.
In Terminal, add the URL for the remote repository where your local
repository will be pushed.
$ git remote add origin remote "repositoryURLgoesHere"
Sets the new remote
$ git remote -v
Verifies the new remote URL
Adding a project to the repo
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am trying to generate a static blog through Pelican and then host it on GitHub.
I have no problem generating a blog locally, but I struggle when I try to push it to GitHub. I have scoured the web looking for instruction, but it seems like the authors skip steps that would be trivial to someone with experience, but not to a beginner.
Could anyone provide a step-by-step guide on how to host a static blog generated with Pelican on GitHub?
Considering you want to push it on your user repository:
To publish a Pelican site in the form of User Pages, you need to push the content of the output dir generated by Pelican to the master branch of your .github.io repository on GitHub.
You can take advantage of ghp-import:
$ pelican content -o output -s pelicanconf.py
$ ghp-import output
$ git push git#github.com:elemoine/elemoine.github.io.git gh-pages:master
The git push command pushes the local gh-pages branch (freshly updated by the ghp-import command) to the elemoine.github.io repository’s master branch on GitHub.
Myself I use a one liner doing the same:
$pelican && ghp-import output && git push git#github.com:maggick/maggick.github.io.git gh-pages:master
(source: http://docs.getpelican.com/en/latest/tips.html)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am making an installer for py2exe packaged app. py2exe catches strerr and put that in log file created in the same folder as executable. So, installing the app into "Program Files" will cause a problem because the app does not have the right to create a file in there.
I do not want to edit the manifest to ask for UAC for the app either. So, I was thinking to configure my installer to use the user home directory as default installation folder.
But user home is meant for documents and photos and such.
(edit) I really want to keep it together with the executable, because i want users to easily locate the log file and send it to me for debugging.
So, is it a bad practice? Any better way around?
py2exe catches strerr and put that in log file created in the same folder as executable
You can override py2exe's default behavior and place log file in specific folder. See py2exe error logging for details.
I would suggest placing log files in AppData/Local folder.
What is the AppData folder?
The AppData folder contains app
settings, files, and data specific to the apps on your PC. The folder
is hidden by default in File Explorer, and has three hidden
sub-folders: Local, LocalLow, and Roaming.
Roaming. This folder (%appdata%) contains data that can move with your user profile from PC to PC—like when you’re on a domain—because
this data has the ability to sync with a server. For example, if you
sign in to a different PC on a domain, your web browser favorites or
bookmarks will be available.
Local. This folder (%localappdata%) contains data that can't move with your user profile. This data is typically specific to a PC or too
large to sync with a server. For example, web browsers usually store
their temporary files here.
LocalLow. This folder (%appdata%/…/locallow) contains data that can't move, but also has a lower level of access. For example, if
you're running a web browser in a protected or safe mode, the app will
only be able access data from the LocalLow folder.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I need an idea how to implement following
1. Want to build python application which will update itself when the new patch is available
2. It will run the unit test to check if the patch deployed successfully
3. If there are any failure during installation it will rollback automatically
What I don't know
A. Not sure how to build a patch from the source code
B. Algorithm / standard process to check about the new updates are available
C. Auto deployment/Rollback process
Any suggestions/ links?
I implementeed a server that recognizes the changed source code and pulls the new code. It is hosted at pythonanywhere.com at this url and the code is on github. This answer bases on my experiences when implementing the update functionality.
When you version your code with git you usually
have a master or deploy branch that works
have a develop branch that is merged into the master-->deploy branch when all the tests run through.
This way you only need to know when the deploy branch changes in order to figure out when to restart. Tests should be run before in order to have no downtime. If you run the tests on the deploy system it may take them too much time or the invalid code destroys the system.
So the deploy branch works because it was tested before.
For automated testing you can use a continous integration server like travis that downloads the code and tests it. It can be asked about whether the test run of a specific commit.
When you host your code on github then you can specify a push http address. I used http://server/update Whenever the repository is changed github notifies your server then.
You can then update the source code by pulling it from git and if the deploy branch really changed then you can restart the application. I can not do this in the server ut maybe you can.
Scenario:
I push code to github
github sends a POST to http://server/update
#post('/update') # bottle code
def pull_own_source_code_and_restart():
with inDirectory(server_repository):
previous_commit = last_commit()
text = git.pull()
current_commit = last_commit()
if previous_commit != current_commit:
restart()
return "Git says: {}".format(text)
have a look at these two files:
command_line.py for the git commands
bottle_app.py for a derivating implementation if the server can not restart itself.
A version control system usually does the 'patching' for every version. I use git. If git is unknown to you now, learn it! Here is workshop material for Pythons Django and git: http://www.opentechschool.org/material.html
Let me now if this information is sufficient to implement such a functionality in Django. Please post your code here when you got it to work.