Trying to upload gz file to Gitlab through the Python Gitlab api - python-3.x

I'm trying to upload a .gz file to gitlab through the python gitlab api. However, the only documentation I have found to do so is through create file.
https://python-gitlab.readthedocs.io/en/stable/gl_objects/projects.html#id7
I have tried with my gz file however, the error code I get is
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
f = project.files.create({'file_path': 'testfile.txt',
'branch': 'master',
'content': file_content,
'author_email': 'test#example.com',
'author_name': 'yourname',
'commit_message': 'Create testfile'})
My expected results would be being able to upload a gz file into Gitlab through the API or other methods.

I ended up using paramiko and connecting through that library. I ended up using ssh.exec_command and typed all my commands followed by a \n in order to work around this issue.

Related

Download multiple file using wget by looping through a text file of IDs

I am trying to download multiple files using wget. I have a text file containing the ID of the files that I want to download (mannifest.tsv, one line for one ID).
Currently, I am using the below command:
while read id; do wget https://target-data.nci.nih.gov/Public/AML/miRNA-seq/L3/expression/BCCA/TARGET-FHCRC/$id.txt; done < manifest.tsv
However, I got the following error:
--2022-08-12 23:43:28-- https://target-data.nci.nih.gov/Public/AML/miRNA-seq/L3/expression/BCCA/TARGET-FHCRC/TARGET-00-BM3897-14A-01R.isoform.quantification%0D.txt
Resolving target-data.nci.nih.gov... 129.43.254.217, 2607:f220:41d:21c1::812b:fed9
Connecting to target-data.nci.nih.gov|129.43.254.217|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-08-12 23:43:30 ERROR 404: Not Found.
Probably because when I loop through manifest.tsv file, the new line character was also read, therefore, the file ID is not correct anymore.
Could someone help me? I really appreciate!

Reading file using python is not working properly in Linux

I'm running a python code where we read a fixed width file, which we extracted from ftp server. the code is working on windows without any issue. but when i am running the same code in the linux ec2 instance it's giving an error saying that "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x99 in position 1819: invalid start byte". but the same code running in windows without any error.since i am not aware about the encoding type of the source file i am passing the encoding type as None. And this also working fine in windows but when we running the code in linux its giving an error saying that "encoding type None is not recognize".
i am using the codecs library to read the file and python version that i am using is 3.7.3
with codecs.open("recode.dat",encoding=None,errors='replace') as open_src:
with open("target_file.dat", 'w+',encoding=None) as open_tgt:
for src_rec in open_src:
new_rec = ''
for f_length in data_type_length:
f_length = int(f_length)
field = '"' + src_rec[:f_length].strip() + '"|'
new_rec += (field)
src_rec = src_rec[f_length:]
open_tgt.write(new_rec[:-1] + '\n')

Getting UnicodeDecodeError: 'utf-8' when robot framework testcases are run in command prompt

Whenever I am trying to run testcases in Robot framework through cmd, i am getting the below error:
Parsing <filename with path> failed UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 31: invalid start byte
The above error thrown for some files and below error for some files
Parsing <filename with path> failed UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 47: invalid start byte
And then my test fails saying there is no such tag in the suite I am referring to, but I have the tag in my file.
Initally I thought it was because of some setting in the editor(STS) I am using and changed the settings under Window-> preferences -> General -> Workspace -> text file encoding option to 'Other' and selected utf-8, gave workspace rebuild, restarted the STS, but still no luck.
Been searching for a solution since weeks. Can someone help me on this?
Checking each and every Testcases by removing and adding them in new file and also by removing all the special characters used in keyword definition as well in testcase definition in the robot files resolved the issue

Is there any way to extract a rar file on cpanel

I have a website script, it 212MB and it's in RAR format , I could not upload it via filezilla ftp , it gave me a timeout error after sometime, I could not upload it from the filemanager of cpanel as it also kept showing an error. Then I used a php script to upload it directly from the link but now I can not extract it as its RAR not ZIP. I converted the RAR into ZIP and have it on drop box and google drive but there is no direct link which I can use to upload via the php script, SO, Is there any way to extract the rar file from cpanel or using a php script or some other tweak. I have been working on it for 2 hours now and can not find a way around.
create a php file and extra the .rar with that php file. use the following code
$archive = RarArchive::open('archive.rar');
$entries = $archive->getEntries();
foreach ($entries as $entry) {
$entry->extract('/extract/to/this/path');
}
$archive->close();

Malformed url exception linux local file system

I have been trying to execute a selenium.attachFile command to upload a file-
sel.attachFile(dom_locator,"/home/xyz/Desktop/tstfl.txt");
but getting a Malformed URL Exception for the file path specified. The file is present in the linux local file system. Please help me with the proper format of the file path.
Likely what you need is
sel.attachFile(dom_locator,"file:///home/xyz/Desktop/tstfl.txt");
For an explanation of file uris, see File URI scheme in wikipedia.

Resources