Showing posts with label archive. Show all posts
Showing posts with label archive. Show all posts

Saturday, May 26, 2018

Retrieving Archived messages from XMPP server in ios

Leave a Comment

I am integrating XMPP functionality in my ios app and i came across a problem i cannot solve. The problem is i cannot get archived messages from the server. My client is able to log in and i have tested several service calls (send, receive messages, getting info about a user) with success.

Upon sending

<iq type='get' id='pref1'>   <pref xmlns='urn:xmpp:archive'/> </iq> 

The response is

SEND: <iq type="get"><pref xmlns="urn:xmpp:archive"/></iq>  RECV: <iq xmlns="jabber:client" type="error" to="1@iis2/ae76edc"><error code="501"     type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp- stanzas"/</error></iq> 

The server administrator is able to see the archived messages, as he activated archiving.

Must something be done server or client side in order to achieve this functionality? Could it be that seeing old messages and the server actually implementing and supporting XEP-0136, are two different things?

0 Answers

Read More

Sunday, September 24, 2017

Python zip multiple directories into one zip file

Leave a Comment

I have a top directory ds237 which has multiple sub-directories under it as below:

ds237/ ├── dataset_description.json ├── derivatives ├── sub-01 ├── sub-02 ├── sub-03 ├── sub-04 ├── sub-05 ├── sub-06 ├── sub-07 ├── sub-08 ├── sub-09 ├── sub-10 ├── sub-11 ├── sub-12 ├── sub-13 ├── sub-21 ├── sub-22 ├── sub-23 ├── sub-24 ├── sub-25 ├── sub-26 ├── sub-27 ├── sub-28 ├── sub-29

I am trying to create multiple zip files(with proper zip names) from ds237 as per size of the zip files. sub01-01.zip: contain sub-01 to sub-07 sub08-13.zip : it contains sub08 to sub-13

I have written a logic which creates a list of sub-directories [sub-01,sub-02, sub-03, sub-04, sub-05]. I have created the list so that the total size of the all sub directories in the list should not be > 5gb.

My question: is how can i write a function to zip these sub-dirs (which are in a list) into a destination zip file with proper name. Basically i want to write a function as follows:

def zipit([list of subdirs], 'path/to/zipfile/sub*-*.zip'):

I linux i generally achieve this by: 'zip -r compress/sub01-08.zip ds237/sub-0[1-8]'

3 Answers

Answers 1

Looking at https://stackoverflow.com/a/1855118/375530, you can re-use that answer's function to add a directory to a ZipFile.

import os import zipfile   def zipdir(path, ziph):     # ziph is zipfile handle     for root, dirs, files in os.walk(path):         for file in files:             ziph.write(os.path.join(root, file),                        os.path.relpath(os.path.join(root, file),                                        os.path.join(path, '..')))   def zipit(dir_list, zip_name):     zipf = zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED)     for dir in dir_list:         zipdir(dir, zipf)     zipf.close() 

The zipit function should be called with your pre-chunked list and a given name. You can use string formatting if you want to use a programmatic name (e.g. "path/to/zipfile/sub{}-{}.zip".format(start, end)).

Answers 2

You can use subprocess calling 'zip' and passing the paths as arguments

Answers 3

The following will give you zip file with a first folder ds100:

import os import zipfile      def zipit(folders, zip_filename):     zip_file = zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED)      for folder in folders:         for dirpath, dirnames, filenames in os.walk(folder):             for filename in filenames:                 zip_file.write(                     os.path.join(dirpath, filename),                     os.path.relpath(os.path.join(dirpath, filename), os.path.join(folders[0], '../..')))      zip_file.close()   folders = [     "/Users/aba/ds100/sub-01",     "/Users/aba/ds100/sub-02",     "/Users/aba/ds100/sub-03",     "/Users/aba/ds100/sub-04",     "/Users/aba/ds100/sub-05"]  zipit(folders, "/Users/aba/ds100/sub01-05.zip") 

For example sub01-05.zip would have a structure similar to:

ds100 ├── sub-01 |   ├── 1 |       ├── 2 |   ├── 1 |   ├── 2 ├── sub-02     ├── 1         ├── 2     ├── 1     ├── 2 
Read More

Tuesday, April 12, 2016

warning 'no explicit ownership' Issue Archive Project XCode

Leave a Comment

in Xcode 7.2.1 I have an issue when I archive my project, my app using WebSocket and I'm using the CocoaAsyncSocket Library, the app runs on Simulator or Any device but when archive, xcode show me this errors warnings:

in the class GCDAsyncUdpSocket in the method:

 - (void)getDelegate:(id <GCDAsyncUdpSocketDelegate>*)delegatePtr delegateQueue:(dispatch_queue_t *)delegateQueuePtr; 

warnings error:

/Users/Dennis/Desktop/WebSocketDennis/CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.m:569:56: Method parameter of type '__autoreleasing id<GCDAsyncUdpSocketDelegate> *' with no explicit ownership 

and

/Users/Dennis/Desktop/WebSocketDennis/CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.m:569:102: Method parameter of type '__autoreleasing dispatch_queue_t *' (aka 'NSObject<OS_dispatch_queue> *__autoreleasing *') with no explicit ownership 

I did try another answers like in:

question 1, question 2 or question 3

but how can I fix this ARC issue if I need an id delegate or dispatch_queue_t

and why this issue appears only when needed archive the project?

0 Answers

Read More