Revision 201baa17 kamaki/cli/commands/pithos.py
b/kamaki/cli/commands/pithos.py | ||
---|---|---|
138 | 138 |
(start, end) = (int(start), int(end)) |
139 | 139 |
self._value = '%s-%s' % (start, end) |
140 | 140 |
|
141 |
|
|
141 | 142 |
# Command specs |
142 | 143 |
|
143 | 144 |
|
... | ... | |
200 | 201 |
def __init__(self, arguments={}, auth_base=None): |
201 | 202 |
super(_file_account_command, self).__init__(arguments, auth_base) |
202 | 203 |
self['account'] = ValueArgument( |
203 |
'Set user account (not permanent)', |
|
204 |
('-A', '--account')) |
|
204 |
'Set user account (not permanent)', ('-A', '--account')) |
|
205 | 205 |
|
206 | 206 |
def _run(self, custom_account=None): |
207 | 207 |
super(_file_account_command, self)._run() |
... | ... | |
224 | 224 |
def __init__(self, arguments={}, auth_base=None): |
225 | 225 |
super(_file_container_command, self).__init__(arguments, auth_base) |
226 | 226 |
self['container'] = ValueArgument( |
227 |
'Set container to work with (temporary)', |
|
228 |
('-C', '--container')) |
|
227 |
'Set container to work with (temporary)', ('-C', '--container')) |
|
229 | 228 |
|
230 | 229 |
def extract_container_and_path( |
231 | 230 |
self, |
... | ... | |
321 | 320 |
prefix=ValueArgument('output starting with prefix', '--prefix'), |
322 | 321 |
delimiter=ValueArgument('show output up to delimiter', '--delimiter'), |
323 | 322 |
path=ValueArgument( |
324 |
'show output starting with prefix up to /', |
|
325 |
'--path'), |
|
323 |
'show output starting with prefix up to /', '--path'), |
|
326 | 324 |
meta=ValueArgument( |
327 |
'show output with specified meta keys', |
|
328 |
'--meta', |
|
325 |
'show output with specified meta keys', '--meta', |
|
329 | 326 |
default=[]), |
330 | 327 |
if_modified_since=ValueArgument( |
331 |
'show output modified since then', |
|
332 |
'--if-modified-since'), |
|
328 |
'show output modified since then', '--if-modified-since'), |
|
333 | 329 |
if_unmodified_since=ValueArgument( |
334 |
'show output not modified since then', |
|
335 |
'--if-unmodified-since'), |
|
330 |
'show output not modified since then', '--if-unmodified-since'), |
|
336 | 331 |
until=DateArgument('show metadata until then', '--until'), |
337 | 332 |
format=ValueArgument( |
338 |
'format to parse until data (default: d/m/Y H:M:S )', |
|
339 |
'--format'), |
|
333 |
'format to parse until data (default: d/m/Y H:M:S )', '--format'), |
|
340 | 334 |
shared=FlagArgument('show only shared', '--shared'), |
341 | 335 |
more=FlagArgument( |
342 | 336 |
'output results in pages (-n to set items per page, default 10)', |
... | ... | |
499 | 493 |
|
500 | 494 |
arguments = dict( |
501 | 495 |
versioning=ValueArgument( |
502 |
'set container versioning (auto/none)', |
|
503 |
'--versioning'), |
|
496 |
'set container versioning (auto/none)', '--versioning'), |
|
504 | 497 |
limit=IntArgument('set default container limit', '--limit'), |
505 | 498 |
meta=KeyValueArgument( |
506 |
'set container metadata (can be repeated)', |
|
507 |
'--meta') |
|
499 |
'set container metadata (can be repeated)', '--meta') |
|
508 | 500 |
) |
509 | 501 |
|
510 | 502 |
@errors.generic.all |
... | ... | |
599 | 591 |
if srcerr.status == 404: |
600 | 592 |
raiseCLIError( |
601 | 593 |
'Source object %s not in source container %s' % ( |
602 |
src_path, |
|
603 |
self.client.container), |
|
594 |
src_path, self.client.container), |
|
604 | 595 |
details=['Hint: --with-prefix to match multiple objects']) |
605 | 596 |
elif srcerr.status not in (204,): |
606 | 597 |
raise |
... | ... | |
610 | 601 |
if not self['recursive']: |
611 | 602 |
raiseCLIError( |
612 | 603 |
'Object %s of cont. %s is a dir' % ( |
613 |
src_path, |
|
614 |
self.client.container), |
|
604 |
src_path, self.client.container), |
|
615 | 605 |
details=['Use --recursive to access directories']) |
616 | 606 |
return (self._get_all, dict(prefix=src_path)) |
617 | 607 |
srcobj['name'] = src_path |
... | ... | |
660 | 650 |
yield (name, self._get_new_object(dst_path or name, add_prefix)) |
661 | 651 |
else: |
662 | 652 |
raiseCLIError('Source path %s conflicts with suffix %s' % ( |
663 |
src_iter['name'], |
|
664 |
self['suffix'])) |
|
653 |
src_iter['name'], self['suffix'])) |
|
665 | 654 |
|
666 | 655 |
def _get_new_object(self, obj, add_prefix): |
667 | 656 |
if self['prefix_replace'] and obj.startswith(self['prefix_replace']): |
... | ... | |
690 | 679 |
|
691 | 680 |
arguments = dict( |
692 | 681 |
destination_account=ValueArgument( |
693 |
'Account to copy to', |
|
694 |
('-a', '--dst-account')), |
|
682 |
'Account to copy to', ('-a', '--dst-account')), |
|
695 | 683 |
destination_container=ValueArgument( |
696 | 684 |
'use it if destination container name contains a : character', |
697 | 685 |
('-D', '--dst-container')), |
698 | 686 |
public=ValueArgument('make object publicly accessible', '--public'), |
699 | 687 |
content_type=ValueArgument( |
700 |
'change object\'s content type', |
|
701 |
'--content-type'), |
|
688 |
'change object\'s content type', '--content-type'), |
|
702 | 689 |
recursive=FlagArgument( |
703 |
'copy directory and contents', |
|
704 |
('-R', '--recursive')), |
|
690 |
'copy directory and contents', ('-R', '--recursive')), |
|
705 | 691 |
prefix=FlagArgument( |
706 | 692 |
'Match objects prefixed with src path (feels like src_path*)', |
707 | 693 |
'--with-prefix', |
708 | 694 |
default=''), |
709 | 695 |
suffix=ValueArgument( |
710 |
'Suffix of source objects (feels like *suffix)', |
|
711 |
'--with-suffix', |
|
696 |
'Suffix of source objects (feels like *suffix)', '--with-suffix', |
|
712 | 697 |
default=''), |
713 | 698 |
add_prefix=ValueArgument('Prefix targets', '--add-prefix', default=''), |
714 | 699 |
add_suffix=ValueArgument('Suffix targets', '--add-suffix', default=''), |
... | ... | |
721 | 706 |
'--suffix-to-replace', |
722 | 707 |
default=''), |
723 | 708 |
source_version=ValueArgument( |
724 |
'copy specific version', |
|
725 |
('-S', '--source-version')) |
|
709 |
'copy specific version', ('-S', '--source-version')) |
|
726 | 710 |
) |
727 | 711 |
|
728 | 712 |
@errors.generic.all |
... | ... | |
747 | 731 |
content_type=self['content_type']) |
748 | 732 |
if no_source_object: |
749 | 733 |
raiseCLIError('No object %s in container %s' % ( |
750 |
self.path, |
|
751 |
self.container)) |
|
734 |
self.path, self.container)) |
|
752 | 735 |
self._optional_output(r) |
753 | 736 |
|
754 | 737 |
def main( |
... | ... | |
782 | 765 |
|
783 | 766 |
arguments = dict( |
784 | 767 |
destination_account=ValueArgument( |
785 |
'Account to move to', |
|
786 |
('-a', '--dst-account')), |
|
768 |
'Account to move to', ('-a', '--dst-account')), |
|
787 | 769 |
destination_container=ValueArgument( |
788 | 770 |
'use it if destination container name contains a : character', |
789 | 771 |
('-D', '--dst-container')), |
790 | 772 |
public=ValueArgument('make object publicly accessible', '--public'), |
791 | 773 |
content_type=ValueArgument( |
792 |
'change object\'s content type', |
|
793 |
'--content-type'), |
|
774 |
'change object\'s content type', '--content-type'), |
|
794 | 775 |
recursive=FlagArgument( |
795 |
'copy directory and contents', |
|
796 |
('-R', '--recursive')), |
|
776 |
'copy directory and contents', ('-R', '--recursive')), |
|
797 | 777 |
prefix=FlagArgument( |
798 | 778 |
'Match objects prefixed with src path (feels like src_path*)', |
799 | 779 |
'--with-prefix', |
800 | 780 |
default=''), |
801 | 781 |
suffix=ValueArgument( |
802 |
'Suffix of source objects (feels like *suffix)', |
|
803 |
'--with-suffix', |
|
782 |
'Suffix of source objects (feels like *suffix)', '--with-suffix', |
|
804 | 783 |
default=''), |
805 | 784 |
add_prefix=ValueArgument('Prefix targets', '--add-prefix', default=''), |
806 | 785 |
add_suffix=ValueArgument('Suffix targets', '--add-suffix', default=''), |
... | ... | |
884 | 863 |
|
885 | 864 |
def main(self, local_path, container___path): |
886 | 865 |
super(self.__class__, self)._run( |
887 |
container___path, |
|
888 |
path_is_optional=False) |
|
866 |
container___path, path_is_optional=False) |
|
889 | 867 |
self._run(local_path) |
890 | 868 |
|
891 | 869 |
|
... | ... | |
952 | 930 |
|
953 | 931 |
def main(self, local_path, container___path, start, end): |
954 | 932 |
super(self.__class__, self)._run( |
955 |
container___path, |
|
956 |
path_is_optional=None) |
|
933 |
container___path, path_is_optional=None) |
|
957 | 934 |
self.path = self.path or path.basename(local_path) |
958 | 935 |
self._run(local_path=local_path, start=start, end=end) |
959 | 936 |
|
... | ... | |
974 | 951 |
arguments = dict( |
975 | 952 |
etag=ValueArgument('check written data', '--etag'), |
976 | 953 |
content_encoding=ValueArgument( |
977 |
'set MIME content type', |
|
978 |
'--content-encoding'), |
|
954 |
'set MIME content type', '--content-encoding'), |
|
979 | 955 |
content_disposition=ValueArgument( |
980 |
'the presentation style of the object', |
|
981 |
'--content-disposition'), |
|
956 |
'the presentation style of the object', '--content-disposition'), |
|
982 | 957 |
content_type=ValueArgument( |
983 |
'specify content type', |
|
984 |
'--content-type', |
|
958 |
'specify content type', '--content-type', |
|
985 | 959 |
default='application/octet-stream'), |
986 | 960 |
sharing=SharingArgument( |
987 | 961 |
'\n'.join([ |
... | ... | |
1006 | 980 |
|
1007 | 981 |
def main(self, container___path): |
1008 | 982 |
super(self.__class__, self)._run( |
1009 |
container___path, |
|
1010 |
path_is_optional=False) |
|
983 |
container___path, path_is_optional=False) |
|
1011 | 984 |
self.run() |
1012 | 985 |
|
1013 | 986 |
|
... | ... | |
1017 | 990 |
|
1018 | 991 |
arguments = dict( |
1019 | 992 |
use_hashes=FlagArgument( |
1020 |
'provide hashmap file instead of data', |
|
1021 |
'--use-hashes'), |
|
993 |
'provide hashmap file instead of data', '--use-hashes'), |
|
1022 | 994 |
etag=ValueArgument('check written data', '--etag'), |
1023 | 995 |
unchunked=FlagArgument('avoid chunked transfer mode', '--unchunked'), |
1024 | 996 |
content_encoding=ValueArgument( |
1025 |
'set MIME content type', |
|
1026 |
'--content-encoding'), |
|
997 |
'set MIME content type', '--content-encoding'), |
|
1027 | 998 |
content_disposition=ValueArgument( |
1028 |
'specify objects presentation style', |
|
1029 |
'--content-disposition'), |
|
999 |
'specify objects presentation style', '--content-disposition'), |
|
1030 | 1000 |
content_type=ValueArgument('specify content type', '--content-type'), |
1031 | 1001 |
sharing=SharingArgument( |
1032 | 1002 |
help='\n'.join([ |
... | ... | |
1199 | 1169 |
range=RangeArgument('show range of data', '--range'), |
1200 | 1170 |
if_match=ValueArgument('show output if ETags match', '--if-match'), |
1201 | 1171 |
if_none_match=ValueArgument( |
1202 |
'show output if ETags match', |
|
1203 |
'--if-none-match'), |
|
1172 |
'show output if ETags match', '--if-none-match'), |
|
1204 | 1173 |
if_modified_since=DateArgument( |
1205 |
'show output modified since then', |
|
1206 |
'--if-modified-since'), |
|
1174 |
'show output modified since then', '--if-modified-since'), |
|
1207 | 1175 |
if_unmodified_since=DateArgument( |
1208 |
'show output unmodified since then', |
|
1209 |
'--if-unmodified-since'), |
|
1176 |
'show output unmodified since then', '--if-unmodified-since'), |
|
1210 | 1177 |
object_version=ValueArgument( |
1211 |
'get the specific version', |
|
1212 |
('-O', '--object-version')) |
|
1178 |
'get the specific version', ('-O', '--object-version')) |
|
1213 | 1179 |
) |
1214 | 1180 |
|
1215 | 1181 |
@errors.generic.all |
... | ... | |
1229 | 1195 |
|
1230 | 1196 |
def main(self, container___path): |
1231 | 1197 |
super(self.__class__, self)._run( |
1232 |
container___path, |
|
1233 |
path_is_optional=False) |
|
1198 |
container___path, path_is_optional=False) |
|
1234 | 1199 |
self._run() |
1235 | 1200 |
|
1236 | 1201 |
|
... | ... | |
1253 | 1218 |
range=RangeArgument('show range of data', '--range'), |
1254 | 1219 |
if_match=ValueArgument('show output if ETags match', '--if-match'), |
1255 | 1220 |
if_none_match=ValueArgument( |
1256 |
'show output if ETags match', |
|
1257 |
'--if-none-match'), |
|
1221 |
'show output if ETags match', '--if-none-match'), |
|
1258 | 1222 |
if_modified_since=DateArgument( |
1259 |
'show output modified since then', |
|
1260 |
'--if-modified-since'), |
|
1223 |
'show output modified since then', '--if-modified-since'), |
|
1261 | 1224 |
if_unmodified_since=DateArgument( |
1262 |
'show output unmodified since then', |
|
1263 |
'--if-unmodified-since'), |
|
1225 |
'show output unmodified since then', '--if-unmodified-since'), |
|
1264 | 1226 |
object_version=ValueArgument( |
1265 |
'get the specific version', |
|
1266 |
('-O', '--object-version')), |
|
1227 |
'get the specific version', ('-O', '--object-version')), |
|
1267 | 1228 |
poolsize=IntArgument('set pool size', '--with-pool-size'), |
1268 | 1229 |
progress_bar=ProgressBarArgument( |
1269 | 1230 |
'do not show progress bar', |
... | ... | |
1382 | 1343 |
@errors.pithos.object_path |
1383 | 1344 |
@errors.pithos.local_path |
1384 | 1345 |
def _run(self, local_path): |
1385 |
#outputs = self._outputs(local_path) |
|
1386 | 1346 |
poolsize = self['poolsize'] |
1387 | 1347 |
if poolsize: |
1388 | 1348 |
self.client.MAX_THREADS = int(poolsize) |
... | ... | |
1590 | 1550 |
|
1591 | 1551 |
def main(self, container___path): |
1592 | 1552 |
super(self.__class__, self)._run( |
1593 |
container___path, |
|
1594 |
path_is_optional=False) |
|
1553 |
container___path, path_is_optional=False) |
|
1595 | 1554 |
self._run() |
1596 | 1555 |
|
1597 | 1556 |
|
... | ... | |
1608 | 1567 |
|
1609 | 1568 |
def main(self, container___path): |
1610 | 1569 |
super(self.__class__, self)._run( |
1611 |
container___path, |
|
1612 |
path_is_optional=False) |
|
1570 |
container___path, path_is_optional=False) |
|
1613 | 1571 |
self._run() |
1614 | 1572 |
|
1615 | 1573 |
|
... | ... | |
1648 | 1606 |
|
1649 | 1607 |
def main(self, container___path): |
1650 | 1608 |
super(self.__class__, self)._run( |
1651 |
container___path, |
|
1652 |
path_is_optional=False) |
|
1609 |
container___path, path_is_optional=False) |
|
1653 | 1610 |
self._run() |
1654 | 1611 |
|
1655 | 1612 |
|
... | ... | |
1685 | 1642 |
@errors.pithos.object_path |
1686 | 1643 |
def _run(self, read, write): |
1687 | 1644 |
self._optional_output(self.client.set_object_sharing( |
1688 |
self.path, |
|
1689 |
read_permission=read, write_permission=write)) |
|
1645 |
self.path, read_permission=read, write_permission=write)) |
|
1690 | 1646 |
|
1691 | 1647 |
def main(self, container___path, *permissions): |
1692 | 1648 |
super(self.__class__, self)._run( |
1693 |
container___path, |
|
1694 |
path_is_optional=False) |
|
1695 |
(read, write) = self.format_permission_dict(permissions) |
|
1649 |
container___path, path_is_optional=False) |
|
1650 |
read, write = self.format_permission_dict(permissions) |
|
1696 | 1651 |
self._run(read, write) |
1697 | 1652 |
|
1698 | 1653 |
|
... | ... | |
1711 | 1666 |
|
1712 | 1667 |
def main(self, container___path): |
1713 | 1668 |
super(self.__class__, self)._run( |
1714 |
container___path, |
|
1715 |
path_is_optional=False) |
|
1669 |
container___path, path_is_optional=False) |
|
1716 | 1670 |
self._run() |
1717 | 1671 |
|
1718 | 1672 |
|
... | ... | |
1741 | 1695 |
r = self.client.get_container_info(self.container) |
1742 | 1696 |
else: |
1743 | 1697 |
r = self.client.get_object_info( |
1744 |
self.path, |
|
1745 |
version=self['object_version']) |
|
1698 |
self.path, version=self['object_version']) |
|
1746 | 1699 |
self._print(r, print_dict) |
1747 | 1700 |
|
1748 | 1701 |
def main(self, container____path__=None): |
... | ... | |
1978 | 1931 |
@errors.pithos.connection |
1979 | 1932 |
@errors.pithos.container |
1980 | 1933 |
def _run(self): |
1981 |
#if self.container: |
|
1982 |
# r = self.client.get_container_versioning(self.container) |
|
1983 |
#else: |
|
1984 |
# r = self.client.get_account_versioning() |
|
1985 | 1934 |
self._print( |
1986 | 1935 |
self.client.get_container_versioning(self.container) if ( |
1987 | 1936 |
self.container) else self.client.get_account_versioning(), |
Also available in: Unified diff